The Gaudi Framework  v36r1 (3e2fb5a8)
GaudiKernel.PropertyProxy Namespace Reference

Classes

class  DataHandlePropertyProxy
 
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-2020 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 45 of file PropertyProxy.py.

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

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

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

◆ PropertyProxyFactory()

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

Definition at line 434 of file PropertyProxy.py.

434 def PropertyProxyFactory(descr, doc, default):
435  # print "PropertyProxyFactory( %s, %r )" % (descr.__name__,default)
436 
437  if isinstance(default, GaudiHandleArray):
438  return GaudiHandleArrayPropertyProxy(descr, doc, default)
439 
440  if isinstance(default, GaudiHandle):
441  return GaudiHandlePropertyProxy(descr, doc, default)
442 
443  if isinstance(default, DataHandle):
444  return DataHandlePropertyProxy(descr, doc, default)
445 
446  return PropertyProxy(descr, doc, default)

Variable Documentation

◆ __all__

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

(c) Copyright 1998-2020 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 27 of file PropertyProxy.py.

compareRootHistos.tp
tuple tp
Definition: compareRootHistos.py:461
GaudiKernel.PropertyProxy._isCompatible
def _isCompatible(tp, value)
Definition: PropertyProxy.py:45
GaudiKernel.PropertyProxy.derives_from
def derives_from(derived, base)
Definition: PropertyProxy.py:30
GaudiKernel.PropertyProxy.PropertyProxyFactory
def PropertyProxyFactory(descr, doc, default)
Definition: PropertyProxy.py:434
gaudirun.type
type
Definition: gaudirun.py:154
PropertyProxy
Definition: PropertyProxy.h:24