The Gaudi Framework  v36r1 (3e2fb5a8)
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 260 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 263 of file Bindings.py.

263  def __init__(self, name, ip=cppyy.nullptr):
264  self.__dict__['_ip'] = InterfaceCast(gbl.IProperty)(ip)
265  self.__dict__['_svcloc'] = gbl.Gaudi.svcLocator()
266  self.__dict__['_name'] = name
267 

Member Function Documentation

◆ __call_interface_method__()

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

Definition at line 276 of file Bindings.py.

276  def __call_interface_method__(self, ifname, method, *args):
277  if not getattr(self, ifname):
278  self.retrieveInterface()
279  return getattr(getattr(self, ifname), method)(*args)
280 

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

306  def __getattr__(self, name):
307  """
308  The method which returns the value for the given property
309  - In the case of the valid instance it returns the valid property value through IProperty interface
310  - In the case of placeholder the property value is retrieved from JobOptionsCatalogue
311  """
312  ip = self.getInterface()
313  if ip:
314  if not gbl.Gaudi.Utils.hasProperty(ip, name):
315  raise AttributeError('property %s does not exist' % name)
316  prop = ip.getProperty(name)
317  if StringProperty == type(prop):
318  return prop.value()
319  elif StringPropertyRef == type(prop):
320  return prop.value()
321  try:
322  return eval(prop.toString(), {}, {})
323  except:
324  return prop.value()
325  else:
326  opts = self._svcloc.getOptsSvc()
327  if opts.has("{}.{}".format(self._name, name)):
328  # from JobOptionsSvc we always have only strings
329  return eval(opts.get("{}.{}".format(self._name, name)), {}, {})
330  raise AttributeError('property %s does not exist' % name)
331 

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

281  def __setattr__(self, name, value):
282  """
283  The method which is used for setting the property from the given value.
284  - In the case of the valid instance it sets the property through IProperty interface
285  - In the case of placeholder the property is added to JobOptionsCatalogue
286  """
287  if hasattr(value, 'toStringProperty'):
288  # user defined behaviour
289  value = str(value.toStringProperty())
290  elif hasattr(value, 'toString'):
291  value = str(value.toString())
292  elif type(value) == long:
293  value = '%d' % value # prevent pending 'L'
294  else:
295  value = str(value)
296 
297  ip = self.getInterface()
298  if ip:
299  if not gbl.Gaudi.Utils.hasProperty(ip, name):
300  raise AttributeError('property %s does not exist' % name)
301  ip.setPropertyRepr(name, value)
302  else:
303  gbl.GaudiPython.Helpers.setProperty(self._svcloc, '.'.join(
304  [self._name, name]), value)
305 

◆ getInterface()

def GaudiPython.Bindings.iProperty.getInterface (   self)

Definition at line 268 of file Bindings.py.

268  def getInterface(self):
269  if not self._ip:
270  self.retrieveInterface()
271  return self._ip
272 

◆ name()

def GaudiPython.Bindings.iProperty.name (   self)

Reimplemented in GaudiPython.Bindings.iAlgTool.

Definition at line 353 of file Bindings.py.

353  def name(self):
354  return self._name
355 
356 
357 # ----iService class-----------------------------------------------------------
358 
359 

◆ properties()

def GaudiPython.Bindings.iProperty.properties (   self)

Definition at line 332 of file Bindings.py.

332  def properties(self):
333  dct = {}
334  props = None
335  ip = self.getInterface()
336  if ip:
337  props = ip.getProperties()
338  propsFrom = self._name # "interface"
339  else:
340  raise NotImplementedError("rely on IJobOptionsSvc")
341  props = self._optsvc.getProperties(self._name)
342  propsFrom = "jobOptionsSvc"
343  if props:
344  for p in props:
345  try:
346  dct[p.name()] = PropertyEntry(p)
347  except (ValueError, TypeError) as e:
348  raise ValueError("gaudimodule.iProperty.properties(): %s%s processing property %s.%s = %s" % \
349  (e.__class__.__name__, e.args,
350  propsFrom, p.name(), p.value()))
351  return dct
352 

◆ retrieveInterface()

def GaudiPython.Bindings.iProperty.retrieveInterface (   self)

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

Definition at line 273 of file Bindings.py.

273  def retrieveInterface(self):
274  pass
275 

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