The Gaudi Framework  v36r7 (7f57a304)
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 289 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 292 of file Bindings.py.

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

Member Function Documentation

◆ __call_interface_method__()

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

Definition at line 305 of file Bindings.py.

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

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

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

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

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

◆ getInterface()

def GaudiPython.Bindings.iProperty.getInterface (   self)

Definition at line 297 of file Bindings.py.

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

◆ name()

def GaudiPython.Bindings.iProperty.name (   self)

Reimplemented in GaudiPython.Bindings.iAlgTool.

Definition at line 384 of file Bindings.py.

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

◆ properties()

def GaudiPython.Bindings.iProperty.properties (   self)

Definition at line 362 of file Bindings.py.

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

◆ retrieveInterface()

def GaudiPython.Bindings.iProperty.retrieveInterface (   self)

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

Definition at line 302 of file Bindings.py.

302  def retrieveInterface(self):
303  pass
304 

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