The Gaudi Framework  master (ff829712)
Loading...
Searching...
No Matches
GaudiKernel.PropertyProxy Namespace Reference

Classes

class  DataHandlePropertyProxy
 
class  GaudiHandleArrayPropertyProxy
 
class  GaudiHandlePropertyProxy
 
class  GaudiHandlePropertyProxyBase
 
class  PropertyProxy
 

Functions

 derives_from (derived, base)
 
 _isCompatible (tp, value, name)
 
 _registerConfigurables (allConfigurables, c)
 
 PropertyProxyFactory (descr, doc, default)
 

Variables

list __all__ = ["PropertyProxy", "GaudiHandlePropertyProxy", "GaudiHandleArrayPropertyProxy"]
 (c) Copyright 1998-2025 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".
 
 log = logging.getLogger("PropertyProxy")
 

Function Documentation

◆ _isCompatible()

GaudiKernel.PropertyProxy._isCompatible ( tp,
value,
name )
protected

Definition at line 43 of file PropertyProxy.py.

43def _isCompatible(tp, value, name):
44 errmsg = (
45 f"received an instance of {type(value)}, but {tp} expected for property {name}"
46 )
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 isinstance(value, 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, set):
62 if type(value) is tp:
63 # Check that the types match for collections (GAUDI-207)
64 return value
65 elif tp is set and isinstance(value, list):
66 # Fall-through to implicit conversion for backwards compatibility
67 pass
68 else:
69 raise ValueError(errmsg)
70 elif derives_from(tp, "Configurable"):
71 return value
72
73 # all other types: accept if conversion allowed
74 try:
75 dummy = tp(value)
76 except (TypeError, ValueError):
77 raise ValueError(errmsg)
78
79 return dummy # in case of e.g. classes with __int__, __iter__, etc. implemented
80
81

◆ _registerConfigurables()

GaudiKernel.PropertyProxy._registerConfigurables ( allConfigurables,
c )
protected

Definition at line 82 of file PropertyProxy.py.

82def _registerConfigurables(allConfigurables, c):
83 allConfigurables[c.name()] = c
84 for cc in c.getAllChildren():
85 _registerConfigurables(allConfigurables, cc)
86 return
87
88

◆ derives_from()

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.

28def 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()

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

Definition at line 479 of file PropertyProxy.py.

479def PropertyProxyFactory(descr, doc, default):
480 # print "PropertyProxyFactory( %s, %r )" % (descr.__name__,default)
481
482 if isinstance(default, GaudiHandleArray):
483 return GaudiHandleArrayPropertyProxy(descr, doc, default)
484
485 if isinstance(default, GaudiHandle):
486 return GaudiHandlePropertyProxy(descr, doc, default)
487
488 if isinstance(default, DataHandle):
489 return DataHandlePropertyProxy(descr, doc, default)
490
491 return PropertyProxy(descr, doc, default)
Trivial Algorithm for tutotial purposes.

Variable Documentation

◆ __all__

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

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