The Gaudi Framework  v38r0 (2143aa4c)
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 282 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 285 of file Bindings.py.

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

Member Function Documentation

◆ __call_interface_method__()

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

Definition at line 298 of file Bindings.py.

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

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

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

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

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

◆ getInterface()

def GaudiPython.Bindings.iProperty.getInterface (   self)

Definition at line 290 of file Bindings.py.

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

◆ name()

def GaudiPython.Bindings.iProperty.name (   self)

Reimplemented in GaudiPython.Bindings.iAlgTool.

Definition at line 375 of file Bindings.py.

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

◆ properties()

def GaudiPython.Bindings.iProperty.properties (   self)

Definition at line 353 of file Bindings.py.

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

◆ retrieveInterface()

def GaudiPython.Bindings.iProperty.retrieveInterface (   self)

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

Definition at line 295 of file Bindings.py.

295  def retrieveInterface(self):
296  pass
297 

The documentation for this class was generated from the following file:
bug_34121.name
name
Definition: bug_34121.py:20
GaudiPartProp.decorators.__getattr__
__getattr__
decorate the attribute access for Gaudi.ParticleProperty
Definition: decorators.py:185
GaudiPartProp.Service.InterfaceCast
InterfaceCast
Definition: Service.py:39
format
GAUDI_API std::string format(const char *,...)
MsgStream format utility "a la sprintf(...)".
Definition: MsgStream.cpp:119
gaudiComponentHelp.properties
properties
Definition: gaudiComponentHelp.py:68
gaudirun.type
type
Definition: gaudirun.py:160