The Gaudi Framework  v36r16 (ea80daf8)
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 287 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 290 of file Bindings.py.

290  def __init__(self, name, ip=cppyy.nullptr):
291  self.__dict__["_ip"] = InterfaceCast(gbl.IProperty)(ip)
292  self.__dict__["_svcloc"] = gbl.Gaudi.svcLocator()
293  self.__dict__["_name"] = name
294 

Member Function Documentation

◆ __call_interface_method__()

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

Definition at line 303 of file Bindings.py.

303  def __call_interface_method__(self, ifname, method, *args):
304  if not getattr(self, ifname):
305  self.retrieveInterface()
306  return getattr(getattr(self, ifname), method)(*args)
307 

◆ __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 334 of file Bindings.py.

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

◆ __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 308 of file Bindings.py.

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

◆ getInterface()

def GaudiPython.Bindings.iProperty.getInterface (   self)

Definition at line 295 of file Bindings.py.

295  def getInterface(self):
296  if not self._ip:
297  self.retrieveInterface()
298  return self._ip
299 

◆ name()

def GaudiPython.Bindings.iProperty.name (   self)

Reimplemented in GaudiPython.Bindings.iAlgTool.

Definition at line 382 of file Bindings.py.

382  def name(self):
383  return self._name
384 
385 
386 # ----iService class-----------------------------------------------------------
387 
388 

◆ properties()

def GaudiPython.Bindings.iProperty.properties (   self)

Definition at line 360 of file Bindings.py.

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

◆ retrieveInterface()

def GaudiPython.Bindings.iProperty.retrieveInterface (   self)

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

Definition at line 300 of file Bindings.py.

300  def retrieveInterface(self):
301  pass
302 

The documentation for this class was generated from the following file:
TimingHistograms.name
name
Definition: TimingHistograms.py:25
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