The Gaudi Framework  v37r1 (a7f61348)
GaudiPython.Bindings.iProperty Class Reference
Inheritance diagram for GaudiPython.Bindings.iProperty:
Collaboration diagram for GaudiPython.Bindings.iProperty:

Public Member Functions

def __init__ (self, name, ip=cppyy.nullptr)
 
def getInterface (self)
 
def retrieveInterface (self)
 
def __call_interface_method__ (self, ifname, method, *args)
 
def __setattr__ (self, name, value)
 
def __getattr__ (self, name)
 
def properties (self)
 
def name (self)
 

Detailed Description

Python equivalent to the C++ Property interface

Definition at line 283 of file Bindings.py.

Constructor & Destructor Documentation

◆ __init__()

def GaudiPython.Bindings.iProperty.__init__ (   self,
  name,
  ip = cppyy.nullptr 
)

Reimplemented in GaudiPython.Bindings.iToolSvc, GaudiPython.Bindings.iAlgTool, GaudiPython.Bindings.iService, GaudiPython.Bindings.iNTupleSvc, GaudiPython.Bindings.iHistogramSvc, GaudiPython.Bindings.iDataSvc, and GaudiPython.Bindings.iAlgorithm.

Definition at line 286 of file Bindings.py.

286  def __init__(self, name, ip=cppyy.nullptr):
287  self.__dict__["_ip"] = InterfaceCast(gbl.IProperty)(ip)
288  self.__dict__["_svcloc"] = gbl.Gaudi.svcLocator()
289  self.__dict__["_name"] = name
290 

Member Function Documentation

◆ __call_interface_method__()

def GaudiPython.Bindings.iProperty.__call_interface_method__ (   self,
  ifname,
  method,
args 
)

Definition at line 299 of file Bindings.py.

299  def __call_interface_method__(self, ifname, method, *args):
300  if not getattr(self, ifname):
301  self.retrieveInterface()
302  return getattr(getattr(self, ifname), method)(*args)
303 

◆ __getattr__()

def GaudiPython.Bindings.iProperty.__getattr__ (   self,
  name 
)
The method which returns the value for the given property
- In the case of the valid instance it returns the valid property value through IProperty interface
- In the case of placeholder the property value is retrieved from JobOptionsCatalogue

Definition at line 328 of file Bindings.py.

328  def __getattr__(self, name):
329  """
330  The method which returns the value for the given property
331  - In the case of the valid instance it returns the valid property value through IProperty interface
332  - In the case of placeholder the property value is retrieved from JobOptionsCatalogue
333  """
334  ip = self.getInterface()
335  if ip:
336  if not gbl.Gaudi.Utils.hasProperty(ip, name):
337  raise AttributeError("property %s does not exist" % name)
338  prop = ip.getProperty(name)
339  if StringProperty == type(prop):
340  return prop.value()
341  elif StringPropertyRef == type(prop):
342  return prop.value()
343  try:
344  return eval(prop.toString(), {}, {})
345  except Exception:
346  return prop.value()
347  else:
348  opts = self._svcloc.getOptsSvc()
349  if opts.has("{}.{}".format(self._name, name)):
350  # from JobOptionsSvc we always have only strings
351  return eval(opts.get("{}.{}".format(self._name, name)), {}, {})
352  raise AttributeError("property %s does not exist" % name)
353 

◆ __setattr__()

def GaudiPython.Bindings.iProperty.__setattr__ (   self,
  name,
  value 
)
The method which is used for setting the property from the given value.
- In the case of the valid instance it sets the property through IProperty interface
- In the case of placeholder the property is added to JobOptionsCatalogue

Definition at line 304 of file Bindings.py.

304  def __setattr__(self, name, value):
305  """
306  The method which is used for setting the property from the given value.
307  - In the case of the valid instance it sets the property through IProperty interface
308  - In the case of placeholder the property is added to JobOptionsCatalogue
309  """
310  if hasattr(value, "toStringProperty"):
311  # user defined behaviour
312  value = str(value.toStringProperty())
313  elif hasattr(value, "toString"):
314  value = str(value.toString())
315  else:
316  value = str(value)
317 
318  ip = self.getInterface()
319  if ip:
320  if not gbl.Gaudi.Utils.hasProperty(ip, name):
321  raise AttributeError("property %s does not exist" % name)
322  ip.setPropertyRepr(name, value)
323  else:
324  gbl.GaudiPython.Helpers.setProperty(
325  self._svcloc, ".".join([self._name, name]), value
326  )
327 

◆ getInterface()

def GaudiPython.Bindings.iProperty.getInterface (   self)

Definition at line 291 of file Bindings.py.

291  def getInterface(self):
292  if not self._ip:
293  self.retrieveInterface()
294  return self._ip
295 

◆ name()

def GaudiPython.Bindings.iProperty.name (   self)

Reimplemented in GaudiPython.Bindings.iAlgTool.

Definition at line 376 of file Bindings.py.

376  def name(self):
377  return self._name
378 
379 
380 # ----iService class-----------------------------------------------------------
381 
382 

◆ properties()

def GaudiPython.Bindings.iProperty.properties (   self)

Definition at line 354 of file Bindings.py.

354  def properties(self):
355  dct = {}
356  props = None
357  ip = self.getInterface()
358  if ip:
359  props = ip.getProperties()
360  propsFrom = self._name # "interface"
361  else:
362  raise NotImplementedError("rely on IJobOptionsSvc")
363  props = self._optsvc.getProperties(self._name)
364  propsFrom = "jobOptionsSvc"
365  if props:
366  for p in props:
367  try:
368  dct[p.name()] = PropertyEntry(p)
369  except (ValueError, TypeError) as e:
370  raise ValueError(
371  "gaudimodule.iProperty.properties(): %s%s processing property %s.%s = %s"
372  % (e.__class__.__name__, e.args, propsFrom, p.name(), p.value())
373  )
374  return dct
375 

◆ retrieveInterface()

def GaudiPython.Bindings.iProperty.retrieveInterface (   self)

Reimplemented in GaudiPython.Bindings.iAlgTool, GaudiPython.Bindings.iAlgorithm, and GaudiPython.Bindings.iService.

Definition at line 296 of file Bindings.py.

296  def retrieveInterface(self):
297  pass
298 

The documentation for this class was generated from the following file:
bug_34121.name
name
Definition: bug_34121.py:20
format
GAUDI_API std::string format(const char *,...)
MsgStream format utility "a la sprintf(...)".
Definition: MsgStream.cpp:119
gaudiComponentHelp.properties
properties
Definition: gaudiComponentHelp.py:69
gaudirun.type
type
Definition: gaudirun.py:162