GaudiKernel.PropertyProxy Namespace Reference

Classes

class  DataObjectDescriptorCollectionPropertyProxy
 
class  DataObjectDescriptorPropertyProxy
 
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 31 of file PropertyProxy.py.

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

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

Definition at line 397 of file PropertyProxy.py.

397 def PropertyProxyFactory( descr, doc, default ):
398 # print "PropertyProxyFactory( %s, %r )" % (descr.__name__,default)
399 
400  if isinstance(default,GaudiHandleArray):
401  return GaudiHandleArrayPropertyProxy( descr, doc, default )
402 
403  if isinstance(default,GaudiHandle):
404  return GaudiHandlePropertyProxy( descr, doc, default )
405 
406  if isinstance(default,DataObjectDescriptor):
407  return DataObjectDescriptorPropertyProxy( descr, doc, default )
408 
409  if isinstance(default,DataObjectDescriptorCollection):
410  return DataObjectDescriptorCollectionPropertyProxy( descr, doc, default )
411 
412  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 14 of file PropertyProxy.py.