The Gaudi Framework  v36r11 (bdb84f5f)
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 288 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 291 of file Bindings.py.

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

Member Function Documentation

◆ __call_interface_method__()

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

Definition at line 304 of file Bindings.py.

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

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

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

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

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

◆ getInterface()

def GaudiPython.Bindings.iProperty.getInterface (   self)

Definition at line 296 of file Bindings.py.

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

◆ name()

def GaudiPython.Bindings.iProperty.name (   self)

Reimplemented in GaudiPython.Bindings.iAlgTool.

Definition at line 383 of file Bindings.py.

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

◆ properties()

def GaudiPython.Bindings.iProperty.properties (   self)

Definition at line 361 of file Bindings.py.

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

◆ retrieveInterface()

def GaudiPython.Bindings.iProperty.retrieveInterface (   self)

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

Definition at line 301 of file Bindings.py.

301  def retrieveInterface(self):
302  pass
303 

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:160