The Gaudi Framework  v38r1p1 (ae26267b)
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 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, set):
61  if type(value) is tp:
62  # Check that the types match for collections (GAUDI-207)
63  return value
64  elif tp is set and isinstance(value, list):
65  # Fall-through to implicit conversion for backwards compatibility
66  pass
67  else:
68  raise ValueError(errmsg)
69  elif derives_from(tp, "Configurable"):
70  return value
71 
72  # all other types: accept if conversion allowed
73  try:
74  dummy = tp(value)
75  except (TypeError, ValueError):
76  raise ValueError(errmsg)
77 
78  return dummy # in case of e.g. classes with __int__, __iter__, etc. implemented
79 
80 

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

470 def PropertyProxyFactory(descr, doc, default):
471  # print "PropertyProxyFactory( %s, %r )" % (descr.__name__,default)
472 
473  if isinstance(default, GaudiHandleArray):
474  return GaudiHandleArrayPropertyProxy(descr, doc, default)
475 
476  if isinstance(default, GaudiHandle):
477  return GaudiHandlePropertyProxy(descr, doc, default)
478 
479  if isinstance(default, DataHandle):
480  return DataHandlePropertyProxy(descr, doc, default)
481 
482  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 26 of file PropertyProxy.py.

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:470
gaudirun.type
type
Definition: gaudirun.py:160
compareRootHistos.tp
tp
Definition: compareRootHistos.py:489
PropertyProxy
Definition: PropertyProxy.h:24