The Gaudi Framework  master (594c33fa)
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

 __all__
 (c) Copyright 1998-2023 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
 

Function Documentation

◆ _isCompatible()

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

Definition at line 43 of file PropertyProxy.py.

43 def _isCompatible(tp, value):
44  errmsg = "received an instance of %s, but %s expected" % (type(value), tp)
45 
46  if derives_from(value, "PropertyReference"):
47  # TODO: implement type checking for references
48  return value # references are valid
49  if tp is str:
50  if isinstance(value, str) or derives_from(value, "Configurable"):
51  # we can set string properties only from strings or configurables
52  return value
53  elif isinstance(value, DataHandle):
54  # Implicitly convert DataHandle to str for backward
55  # compatiblity in cases like B.Input (str) = A.Output (handle)
56  return str(value)
57  else:
58  raise ValueError(errmsg)
59  elif tp in (list, tuple, dict, set):
60  if type(value) is tp:
61  # Check that the types match for collections (GAUDI-207)
62  return value
63  elif tp is set and isinstance(value, list):
64  # Fall-through to implicit conversion for backwards compatibility
65  pass
66  else:
67  raise ValueError(errmsg)
68  elif derives_from(tp, "Configurable"):
69  return value
70 
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 28 of file PropertyProxy.py.

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

◆ 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__

GaudiKernel.PropertyProxy.__all__
private

(c) Copyright 1998-2023 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

Definition at line 25 of file PropertyProxy.py.

GaudiKernel.PropertyProxy._isCompatible
def _isCompatible(tp, value)
Definition: PropertyProxy.py:43
GaudiKernel.PropertyProxy.derives_from
def derives_from(derived, base)
Definition: PropertyProxy.py:28
GaudiKernel.PropertyProxy.PropertyProxyFactory
def PropertyProxyFactory(descr, doc, default)
Definition: PropertyProxy.py:469
gaudirun.type
type
Definition: gaudirun.py:160
compareRootHistos.tp
tp
Definition: compareRootHistos.py:489
PropertyProxy
Definition: PropertyProxy.h:24