GaudiKernel.PropertyProxy Namespace Reference

Classes

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__ = [ 'PropertyProxy', 'GaudiHandlePropertyProxy', 'GaudiHandleArrayPropertyProxy' ]
 data ------------------------------------------------------------------— More...
 
tuple log = logging.getLogger( 'PropertyProxy' )
 

Function Documentation

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

Definition at line 30 of file PropertyProxy.py.

30 def _isCompatible( tp, value ):
31  errmsg = "received an instance of %s, but %s expected" % (type(value),tp)
32 
33  if derives_from(value, 'PropertyReference'):
34  # TODO: implement type checking for references
35  return value # references are valid
36  if ( tp is str ):
37  if ( type(value) is str ) or derives_from(value, 'Configurable'):
38  # we can set string properties only from strings or configurables
39  return value
40  else:
41  raise ValueError( errmsg )
42  elif ( tp in [ list, tuple, dict ] ):
43  if ( type(value) is tp ):
44  # We need to check that the types match for lists, tuples and
45  # dictionaries (bug #34769).
46  return value
47  else:
48  raise ValueError( errmsg )
49  elif derives_from(tp, 'Configurable'):
50  return value
51  else:
52  # all other types: accept if conversion allowed
53  try:
54  dummy = tp( value )
55  except (TypeError,ValueError):
56  raise ValueError( errmsg )
57 
58  return dummy # in case of e.g. classes with __int__, __iter__, etc. implemented
59 
60 
def _isCompatible(tp, value)
def derives_from(derived, base)
string type
Definition: gaudirun.py:151
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 19 of file PropertyProxy.py.

19 def derives_from(derived,base):
20  """A string version of isinstance().
21  <derived> is either an object instance, or a type
22  <base> is a string containing the name of the base class (or <derived> class)"""
23  if not isinstance(derived,type): derived=type(derived)
24  if derived.__name__ == base: return True
25  for b in derived.__bases__:
26  if derives_from(b,base): return True
27 
28  return False
29 
def derives_from(derived, base)
string type
Definition: gaudirun.py:151
def GaudiKernel.PropertyProxy.PropertyProxyFactory (   descr,
  doc,
  default 
)

Definition at line 348 of file PropertyProxy.py.

348 def PropertyProxyFactory( descr, doc, default ):
349 # print "PropertyProxyFactory( %s, %r )" % (descr.__name__,default)
350  if isinstance(default,GaudiHandleArray):
351  return GaudiHandleArrayPropertyProxy( descr, doc, default )
352 
353  if isinstance(default,GaudiHandle):
354  return GaudiHandlePropertyProxy( descr, doc, default )
355 
356  return PropertyProxy( descr, doc, default )

Variable Documentation

list GaudiKernel.PropertyProxy.__all__ = [ 'PropertyProxy', 'GaudiHandlePropertyProxy', 'GaudiHandleArrayPropertyProxy' ]

data ------------------------------------------------------------------—

Definition at line 6 of file PropertyProxy.py.

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

Definition at line 13 of file PropertyProxy.py.