ATLAS Offline Software
Loading...
Searching...
No Matches
python.PropertyProxy Namespace Reference

Classes

class  DataHandlePropertyProxy
class  GaudiHandleArrayPropertyProxy
class  GaudiHandlePropertyProxy
class  GaudiHandlePropertyProxyBase
class  PropertyProxy

Functions

 derives_from (derived, base)
 _isCompatible (tp, value, context="")
 PropertyProxyFactory (descr, doc, default)

Variables

str __version__ = '2.0.0'
 data ------------------------------------------------------------------—
str __author__ = 'Wim Lavrijsen (WLavrijsen@lbl.gov), Martin Woudstra (Martin.Woudstra@cern.ch)'
list __all__
 log = logging.getLogger( 'PropertyProxy' )

Function Documentation

◆ _isCompatible()

python.PropertyProxy._isCompatible ( tp,
value,
context = "" )
protected

Definition at line 44 of file PropertyProxy.py.

44def _isCompatible( tp, value, context = "" ):
45 # Note: this function is only called for builtin types. Lists of
46 # configurables (most likely GaudiHandleArrays) don't get here, since
47 # their PropertyProxy types are special cases (see below). Thus, a
48 # compatibility check that relies on conversion (which will always fail
49 # for configurables) is acceptable.
50
51 if ( tp == str or type(value) is str ) and not isinstance( value, tp ):
52 # special case, insist on exact match for str (no conversions allowed)
53 raise ValueError( "received an instance of %s, but %s expected, context: %s" % (type(value),tp, context) )
54 elif ( tp == int ) and type(value) is float:
55 # special case, insist on strict match for integer types
56 raise ValueError( "received an instance of %s, but %s expected, context: %s" % (type(value),tp, context) )
57 else:
58 # all other types: accept if conversion allowed
59 try:
60 dummy = tp( value )
61 except ValueError as verr:
62 if isinstance( value, tp ):
63 # this is a conversion mismatch, but an "ok" type (i.e. the type can
64 # not be copied/constructed from itself), which is a typical case
65 # for configurables being added to an ordinary list (as opposed to
66 # a GaudiHandleArray), where the actual type of the list is unknown
67 raise ValueError( "received non-convertible type %s, but builtin type expected, reason: %s context: %s" % (type(value), str(verr), context) )
68 else:
69 # this is a complete miss and the error message will be clear
70 raise ValueError( "received an instance of %s, but %s expected, reason: %s, context: %s" % (type(value),tp, str(verr), context) )
71 except TypeError as terr:
72 raise TypeError( "received an instance of %s, but %s expected, reason: %s, context: %s" % (type(value),tp, str(terr), context) )
73 return dummy # in case of e.g. classes with __int__, __iter__, etc. implemented
74
75

◆ derives_from()

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

27def derives_from( derived, base ):
28 """A string version of isinstance().
29 <derived> is either an object instance, or a type
30 <base> is a string containing the name of the base class (or <derived> class)"""
31 if not isinstance( derived, type ):
32 derived = type(derived)
33
34 if derived.__name__ == base:
35 return True
36
37 for b in derived.__bases__:
38 if derives_from( b,base ):
39 return True
40
41 return False
42
43

◆ PropertyProxyFactory()

python.PropertyProxy.PropertyProxyFactory ( descr,
doc,
default )

Definition at line 444 of file PropertyProxy.py.

444def PropertyProxyFactory( descr, doc, default ):
445# print "PropertyProxyFactory( %s, %r )" % (descr.__name__,default)
446 if isinstance(default,GaudiHandleArray):
447 return GaudiHandleArrayPropertyProxy( descr, doc, default )
448
449 if isinstance(default,GaudiHandle):
450 return GaudiHandlePropertyProxy( descr, doc, default )
451
452 if isinstance(default,DataHandle):
453 return DataHandlePropertyProxy( descr, doc, default )
454
455 return PropertyProxy( descr, doc, default )

Variable Documentation

◆ __all__

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

Definition at line 18 of file PropertyProxy.py.

◆ __author__

str python.PropertyProxy.__author__ = 'Wim Lavrijsen (WLavrijsen@lbl.gov), Martin Woudstra (Martin.Woudstra@cern.ch)'
private

Definition at line 16 of file PropertyProxy.py.

◆ __version__

str python.PropertyProxy.__version__ = '2.0.0'
private

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

Definition at line 15 of file PropertyProxy.py.

◆ log

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

Definition at line 24 of file PropertyProxy.py.