The Gaudi Framework  v33r1 (b1225454)
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__
 (c) Copyright 1998-2019 CERN for the benefit of the LHCb and ATLAS collaborations # # This software is distributed under the terms of the Apache version 2 licence, # copied verbatim in the file "LICENSE". More...
 
 log = logging.getLogger('PropertyProxy')
 

Function Documentation

◆ _isCompatible()

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

Definition at line 49 of file PropertyProxy.py.

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

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

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

◆ PropertyProxyFactory()

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

Definition at line 431 of file PropertyProxy.py.

431 def PropertyProxyFactory(descr, doc, default):
432  # print "PropertyProxyFactory( %s, %r )" % (descr.__name__,default)
433 
434  if isinstance(default, GaudiHandleArray):
435  return GaudiHandleArrayPropertyProxy(descr, doc, default)
436 
437  if isinstance(default, GaudiHandle):
438  return GaudiHandlePropertyProxy(descr, doc, default)
439 
440  if isinstance(default, DataObjectHandleBase):
441  return DataObjectHandleBasePropertyProxy(descr, doc, default)
442 
443  return PropertyProxy(descr, doc, default)
def PropertyProxyFactory(descr, doc, default)

Variable Documentation

◆ __all__

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

(c) Copyright 1998-2019 CERN for the benefit of the LHCb and ATLAS collaborations # # This software is distributed under the terms of the Apache version 2 licence, # copied verbatim in the file "LICENSE".

# # In applying this licence, CERN does not waive the privileges and immunities # granted to it by virtue of its status as an Intergovernmental Organization # or submit itself to any jurisdiction. #

File: AthenaCommon/python/PropertyProxy.py Author: Wim Lavrijsen (WLavr.nosp@m.ijse.nosp@m.n@lbl.nosp@m..gov) Author: Martin Woudstra (Marti.nosp@m.n.Wo.nosp@m.udstr.nosp@m.a@ce.nosp@m.rn.ch)

Definition at line 16 of file PropertyProxy.py.

◆ log

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

Definition at line 28 of file PropertyProxy.py.