| The Gaudi Framework v32r1 (f65d50dc)

Classes | Functions | Variables
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

## ◆ _isCompatible()

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

Definition at line 39 of file PropertyProxy.py.

39 def _isCompatible(tp, value):
40 errmsg = "received an instance of %s, but %s expected" % (type(value), tp)
41
42 if derives_from(value, 'PropertyReference'):
43 # TODO: implement type checking for references
44 return value # references are valid
45 if (tp is str):
46 if (type(value) is str) or derives_from(value, 'Configurable'):
47 # we can set string properties only from strings or configurables
48 return value
49 elif isinstance(value, DataObjectHandleBase):
50 # Implicitly convert DataObjectHandleBase to str for backward
51 # compatiblity in cases like B.Input (str) = A.Output (handle)
52 return str(value)
53 else:
54 raise ValueError(errmsg)
55 elif (tp in [list, tuple, dict]):
56 if (type(value) is tp):
57 # We need to check that the types match for lists, tuples and
58 # dictionaries (bug #34769).
59 return value
60 else:
61 raise ValueError(errmsg)
62 elif derives_from(tp, 'Configurable'):
63 return value
64 else:
65 # all other types: accept if conversion allowed
66 try:
67 dummy = tp(value)
68 except (TypeError, ValueError):
69 raise ValueError(errmsg)
70
71 return dummy # in case of e.g. classes with __int__, __iter__, etc. implemented
72
73
gaudirun.type
type
Definition: gaudirun.py:142
compareRootHistos.tp
tuple tp
Definition: compareRootHistos.py:448
GaudiKernel.PropertyProxy.derives_from
def derives_from(derived, base)
Definition: PropertyProxy.py:24
GaudiKernel.PropertyProxy._isCompatible
def _isCompatible(tp, value)
Definition: PropertyProxy.py:39

## ◆ derives_from()

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 24 of file PropertyProxy.py.

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

## ◆ PropertyProxyFactory()

def GaudiKernel.PropertyProxy.PropertyProxyFactory | ( |  | descr,
|  |  | doc,
|  |  | default
| ) |  |

Definition at line 420 of file PropertyProxy.py.

420 def PropertyProxyFactory(descr, doc, default):
421 # print "PropertyProxyFactory( %s, %r )" % (descr.__name__,default)
422
423 if isinstance(default, GaudiHandleArray):
424 return GaudiHandleArrayPropertyProxy(descr, doc, default)
425
426 if isinstance(default, GaudiHandle):
427 return GaudiHandlePropertyProxy(descr, doc, default)
428
429 if isinstance(default, DataObjectHandleBase):
430 return DataObjectHandleBasePropertyProxy(descr, doc, default)
431
432 return PropertyProxy(descr, doc, default)
GaudiKernel.PropertyProxy.PropertyProxyFactory
def PropertyProxyFactory(descr, doc, default)
Definition: PropertyProxy.py:420

## Variable Documentation

## ◆ __all__

list GaudiKernel.PropertyProxy.__all__
| private

Initial value:
1 = [
2 'PropertyProxy', 'GaudiHandlePropertyProxy',
3 'GaudiHandleArrayPropertyProxy'
4 ]

Definition at line 6 of file PropertyProxy.py.

## ◆ log

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

Definition at line 18 of file PropertyProxy.py.