| The Gaudi Framework v28r2p1 (f1a77ff4)

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Namespace List
- Namespace Members

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__ = [ 'PropertyProxy', 'GaudiHandlePropertyProxy', 'GaudiHandleArrayPropertyProxy' ]
| data ------------------------------------------------------------------— More...
| 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
gaudirun.type
type
Definition: gaudirun.py:125
GaudiKernel.PropertyProxy.derives_from
def derives_from(derived, base)
Definition: PropertyProxy.py:20
GaudiKernel.PropertyProxy._isCompatible
def _isCompatible(tp, value)
Definition: PropertyProxy.py:31

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
gaudirun.type
type
Definition: gaudirun.py:125
GaudiKernel.PropertyProxy.derives_from
def derives_from(derived, base)
Definition: PropertyProxy.py:20

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

Definition at line 385 of file PropertyProxy.py.

385 def PropertyProxyFactory( descr, doc, default ):
386 # print "PropertyProxyFactory( %s, %r )" % (descr.__name__,default)
387
388 if isinstance(default,GaudiHandleArray):
389 return GaudiHandleArrayPropertyProxy( descr, doc, default )
390
391 if isinstance(default,GaudiHandle):
392 return GaudiHandlePropertyProxy( descr, doc, default )
393
394 if isinstance(default,DataObjectHandleBase):
395 return DataObjectHandleBasePropertyProxy( descr, doc, default )
396
397 return PropertyProxy( descr, doc, default )
398
GaudiKernel.PropertyProxy.GaudiHandleArrayPropertyProxy
Definition: PropertyProxy.py:312
GaudiKernel.PropertyProxy.GaudiHandlePropertyProxy
Definition: PropertyProxy.py:307
GaudiKernel.PropertyProxy.PropertyProxy
Definition: PropertyProxy.py:62
GaudiKernel.PropertyProxy.DataObjectHandleBasePropertyProxy
Definition: PropertyProxy.py:347
GaudiKernel.PropertyProxy.PropertyProxyFactory
def PropertyProxyFactory(descr, doc, default)
Definition: PropertyProxy.py:385

## Variable Documentation

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

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

Definition at line 6 of file PropertyProxy.py.

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

Definition at line 14 of file PropertyProxy.py.