ATLAS Offline Software
Loading...
Searching...
No Matches
python.PropertyProxy.PropertyProxy Class Reference
Inheritance diagram for python.PropertyProxy.PropertyProxy:
Collaboration diagram for python.PropertyProxy.PropertyProxy:

Public Types

typedef HLT::TypeInformation::for_each_type_c< typenameEDMLIST::map, my_functor, my_result<>, my_arg< HLT::TypeInformation::get_cont, CONTAINER > >::type result

Public Member Functions

 __init__ (self, descr, docString=None, default=None)
 setDefault (self, value)
 getDefault (self)
 fullPropertyName (self, obj)
 __get__ (self, obj, type=None)
 __set__ (self, obj, value)
 __delete__ (self, obj)

Public Attributes

 history = weakref.WeakKeyDictionary()
 descr = descr

Properties

 default = property( getDefault, setDefault )

Private Attributes

 __doc__ = docString
 __default = value

Detailed Description

Definition at line 76 of file PropertyProxy.py.

Member Typedef Documentation

◆ result

Definition at line 90 of file EDM_MasterSearch.h.

Constructor & Destructor Documentation

◆ __init__()

python.PropertyProxy.PropertyProxy.__init__ ( self,
descr,
docString = None,
default = None )

Definition at line 77 of file PropertyProxy.py.

77 def __init__( self, descr, docString=None, default=None ):
78 self.history = weakref.WeakKeyDictionary()
79 self.descr = descr
80 if docString:
81 self.__doc__ = docString
82 if default is not None:
83 self.default = default
84

Member Function Documentation

◆ __delete__()

python.PropertyProxy.PropertyProxy.__delete__ ( self,
obj )

Definition at line 172 of file PropertyProxy.py.

172 def __delete__( self, obj ):
173 if obj in self.history:
174 del self.history[ obj ]
175 self.descr.__delete__( obj )
176
177
178

◆ __get__()

python.PropertyProxy.PropertyProxy.__get__ ( self,
obj,
type = None )

Definition at line 96 of file PropertyProxy.py.

96 def __get__( self, obj, type = None ):
97 value = None
98 try:
99 value = self.descr.__get__( obj, type )
100 except AttributeError:
101 # special case for list and set: allow default to work with on +=;
102 # unfortunately, that means that direct access also succeeds, even
103 # as the property wasn't set yet ... (TODO: ideas??)
104 if self.__default.__class__ == list or self.__default.__class__ == set:
105 self.descr.__set__( obj, self.__default.__class__(self.__default) )
106 value = self.descr.__get__( obj, type ) # no history
107 else:
108 raise
109
110 if value is None:
111 value = self.descr.__get__( obj, type )
112
113 # locked configurables return copies to prevent modifications
114 if obj.isLocked():
115 import builtins
116 if builtins.type( value ) is dict:
117 from ctypes import pythonapi, py_object
118 from _ctypes import PyObj_FromPtr
119 PyDictProxy_New = pythonapi.PyDictProxy_New
120 PyDictProxy_New.argtypes = (py_object,)
121 PyDictProxy_New.rettype = py_object
122 value = PyObj_FromPtr( PyDictProxy_New( value ) )
123 elif builtins.type( value ) is list:
124 value = tuple( value ) # point being that tuple is read-only
125 else:
126 import copy
127 value = copy.copy( value )
128
129 return value
130

◆ __set__()

python.PropertyProxy.PropertyProxy.__set__ ( self,
obj,
value )

Definition at line 131 of file PropertyProxy.py.

131 def __set__( self, obj, value ):
132 # locked configurables can no longer be changed
133 if obj.isLocked():
134 raise RuntimeError(
135 'can not change property "%s" of locked configurable "%s"' %
136 (self.descr.__name__, obj.getJobOptName()) )
137
138 # check value/property compatibility if possible
139 proptype = None
140 if hasattr( self, 'default' ):
141 proptype = type(self.default)
142 elif obj in self.history:
143 proptype = type( self.history[ obj ][ 0 ] )
144
145 # check if type known; allow special initializer for typed instances
146 if proptype and not isinstance(proptype, type(None)):
147 # check value itself
148 value = _isCompatible( proptype, value, self.fullPropertyName(obj) )
149
150 # check elements in case of list
151 if proptype == tuple or proptype == list:
152 try:
153 oldvec = self.descr.__get__( obj, type )
154 if oldvec:
155 tpo = type(oldvec[0])
156 for v in value:
157 _isCompatible( tpo, v, self.fullPropertyName(obj) )
158 except AttributeError:
159 # value not yet set
160 pass
161
162 # allow a property to be set if we're in non-default mode, or if it
163 # simply hasn't been set before
164 if not obj._isInSetDefaults() or obj not in self.history:
165 # by convention, 'None' for default is used to designate objects setting
166 if hasattr( self, 'default' ) and self.default is None:
167 obj.__iadd__( value, self.descr ) # to establish hierarchy
168 else:
169 self.descr.__set__( obj, value )
170 self.history.setdefault( obj, [] ).append( value )
171

◆ fullPropertyName()

python.PropertyProxy.PropertyProxy.fullPropertyName ( self,
obj )

Definition at line 93 of file PropertyProxy.py.

93 def fullPropertyName( self, obj ):
94 return (obj.getJobOptName() or obj.getName()) + '.' + self.descr.__name__
95

◆ getDefault()

python.PropertyProxy.PropertyProxy.getDefault ( self)

Definition at line 88 of file PropertyProxy.py.

88 def getDefault( self ):
89 return self.__default
90

◆ setDefault()

python.PropertyProxy.PropertyProxy.setDefault ( self,
value )

Definition at line 85 of file PropertyProxy.py.

85 def setDefault( self, value ):
86 self.__default = value
87

Member Data Documentation

◆ __default

python.PropertyProxy.PropertyProxy.__default = value
private

Definition at line 86 of file PropertyProxy.py.

◆ __doc__

python.PropertyProxy.PropertyProxy.__doc__ = docString
private

Definition at line 81 of file PropertyProxy.py.

◆ descr

python.PropertyProxy.PropertyProxy.descr = descr

Definition at line 79 of file PropertyProxy.py.

◆ history

python.PropertyProxy.PropertyProxy.history = weakref.WeakKeyDictionary()

Definition at line 78 of file PropertyProxy.py.

Property Documentation

◆ default

python.PropertyProxy.PropertyProxy.default = property( getDefault, setDefault )
static

Definition at line 91 of file PropertyProxy.py.


The documentation for this class was generated from the following file: