Loading [MathJax]/extensions/tex2jax.js
The Gaudi Framework  v29r0 (ff2e7097)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
GaudiKernel.PropertyProxy Namespace Reference

Classes

class  DataObjectHandleBasePropertyProxy
 
class  GaudiHandleArrayPropertyProxy
 
class  GaudiHandlePropertyProxy
 
class  GaudiHandlePropertyProxyBase
 
class  PropertyProxy
 

Functions

def derives_from (derived, base)
 
def _isCompatible (tp, value)
 
def PropertyProxyFactory (descr, doc, default)
 

Variables

list __all__
 
 log = logging.getLogger('PropertyProxy')
 

Function Documentation

def GaudiKernel.PropertyProxy._isCompatible (   tp,
  value 
)
private

Definition at line 37 of file PropertyProxy.py.

37 def _isCompatible(tp, value):
38  errmsg = "received an instance of %s, but %s expected" % (type(value), tp)
39 
40  if derives_from(value, 'PropertyReference'):
41  # TODO: implement type checking for references
42  return value # references are valid
43  if (tp is str):
44  if (type(value) is str) or derives_from(value, 'Configurable'):
45  # we can set string properties only from strings or configurables
46  return value
47  else:
48  raise ValueError(errmsg)
49  elif (tp in [list, tuple, dict]):
50  if (type(value) is tp):
51  # We need to check that the types match for lists, tuples and
52  # dictionaries (bug #34769).
53  return value
54  else:
55  raise ValueError(errmsg)
56  elif derives_from(tp, 'Configurable'):
57  return value
58  else:
59  # all other types: accept if conversion allowed
60  try:
61  dummy = tp(value)
62  except (TypeError, ValueError):
63  raise ValueError(errmsg)
64 
65  return dummy # in case of e.g. classes with __int__, __iter__, etc. implemented
66 
67 
def derives_from(derived, base)
def _isCompatible(tp, value)
def GaudiKernel.PropertyProxy.derives_from (   derived,
  base 
)
A string version of isinstance().
<derived> is either an object instance, or a type
<base>    is a string containing the name of the base class (or <derived> class)

Definition at line 22 of file PropertyProxy.py.

22 def derives_from(derived, base):
23  """A string version of isinstance().
24  <derived> is either an object instance, or a type
25  <base> is a string containing the name of the base class (or <derived> class)"""
26  if not isinstance(derived, type):
27  derived = type(derived)
28  if derived.__name__ == base:
29  return True
30  for b in derived.__bases__:
31  if derives_from(b, base):
32  return True
33 
34  return False
35 
36 
def derives_from(derived, base)
def GaudiKernel.PropertyProxy.PropertyProxyFactory (   descr,
  doc,
  default 
)

Definition at line 390 of file PropertyProxy.py.

390 def PropertyProxyFactory(descr, doc, default):
391  # print "PropertyProxyFactory( %s, %r )" % (descr.__name__,default)
392 
393  if isinstance(default, GaudiHandleArray):
394  return GaudiHandleArrayPropertyProxy(descr, doc, default)
395 
396  if isinstance(default, GaudiHandle):
397  return GaudiHandlePropertyProxy(descr, doc, default)
398 
399  if isinstance(default, DataObjectHandleBase):
400  return DataObjectHandleBasePropertyProxy(descr, doc, default)
401 
402  return PropertyProxy(descr, doc, default)

Variable Documentation

list GaudiKernel.PropertyProxy.__all__
private
Initial value:
1 = ['PropertyProxy', 'GaudiHandlePropertyProxy',
2  'GaudiHandleArrayPropertyProxy']

Definition at line 6 of file PropertyProxy.py.

GaudiKernel.PropertyProxy.log = logging.getLogger('PropertyProxy')

Definition at line 16 of file PropertyProxy.py.