ATLAS Offline Software
Classes | Functions | Variables
python.PropertyProxy Namespace Reference

Classes

class  DataHandlePropertyProxy
 
class  GaudiHandleArrayPropertyProxy
 
class  GaudiHandlePropertyProxy
 
class  GaudiHandlePropertyProxyBase
 
class  PropertyProxy
 

Functions

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

Variables

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

Function Documentation

◆ _isCompatible()

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

Definition at line 44 of file PropertyProxy.py.

44 def _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()

def 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.

27 def 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()

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

Definition at line 445 of file PropertyProxy.py.

445 def PropertyProxyFactory( descr, doc, default ):
446 # print "PropertyProxyFactory( %s, %r )" % (descr.__name__,default)
447  if isinstance(default,GaudiHandleArray):
448  return GaudiHandleArrayPropertyProxy( descr, doc, default )
449 
450  if isinstance(default,GaudiHandle):
451  return GaudiHandlePropertyProxy( descr, doc, default )
452 
453  if isinstance(default,DataHandle):
454  return DataHandlePropertyProxy( descr, doc, default )
455 
456  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__

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

Definition at line 16 of file PropertyProxy.py.

◆ __version__

string 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.

python.PropertyProxy.derives_from
def derives_from(derived, base)
Definition: PropertyProxy.py:27
python.PropertyProxy.PropertyProxyFactory
def PropertyProxyFactory(descr, doc, default)
Definition: PropertyProxy.py:445
ParticleTest.tp
tp
Definition: ParticleTest.py:25
python.PropertyProxy._isCompatible
def _isCompatible(tp, value, context="")
Definition: PropertyProxy.py:44
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
str
Definition: BTagTrackIpAccessor.cxx:11