The Gaudi Framework  v36r9p1 (5c15b2bb)
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__ = ["PropertyProxy", "GaudiHandlePropertyProxy", "GaudiHandleArrayPropertyProxy"]
 (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 44 of file PropertyProxy.py.

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

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

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

◆ PropertyProxyFactory()

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

Definition at line 469 of file PropertyProxy.py.

469 def PropertyProxyFactory(descr, doc, default):
470  # print "PropertyProxyFactory( %s, %r )" % (descr.__name__,default)
471 
472  if isinstance(default, GaudiHandleArray):
473  return GaudiHandleArrayPropertyProxy(descr, doc, default)
474 
475  if isinstance(default, GaudiHandle):
476  return GaudiHandlePropertyProxy(descr, doc, default)
477 
478  if isinstance(default, DataHandle):
479  return DataHandlePropertyProxy(descr, doc, default)
480 
481  return PropertyProxy(descr, doc, default)

Variable Documentation

◆ __all__

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

(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 26 of file PropertyProxy.py.

compareRootHistos.tp
tuple tp
Definition: compareRootHistos.py:493
GaudiKernel.PropertyProxy._isCompatible
def _isCompatible(tp, value)
Definition: PropertyProxy.py:44
GaudiKernel.PropertyProxy.derives_from
def derives_from(derived, base)
Definition: PropertyProxy.py:29
GaudiKernel.PropertyProxy.PropertyProxyFactory
def PropertyProxyFactory(descr, doc, default)
Definition: PropertyProxy.py:469
gaudirun.type
type
Definition: gaudirun.py:160
PropertyProxy
Definition: PropertyProxy.h:24