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

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, default)
 checkType (self, obj, value)
 convertDefaultToBeSet (self, obj, default)
 convertValueToBeSet (self, obj, value)
 __get__ (self, obj, type=None)
 __set__ (self, obj, value)
 isHandle (self, value)
 isConfig (self, value)
 getDefaultConfigurable (self, typeAndName, requester)
 setDefault (self, value)
 getDefault (self)
 fullPropertyName (self, obj)
 __delete__ (self, obj)

Public Attributes

 arrayType = type(default)
 history = weakref.WeakKeyDictionary()
 descr = descr

Protected Attributes

 _handleType = handleType
str _confTypeName = 'Configurable' + handleType.componentType

Properties

 default = property( getDefault, setDefault )

Private Attributes

 __doc__ = docString
 __default = value

Detailed Description

Definition at line 365 of file PropertyProxy.py.

Member Typedef Documentation

◆ result

Definition at line 90 of file EDM_MasterSearch.h.

Constructor & Destructor Documentation

◆ __init__()

python.PropertyProxy.GaudiHandleArrayPropertyProxy.__init__ ( self,
descr,
docString,
default )
<descr>: the real property in the object instance (from __slots__)
<confTypeName>: string indicating the (base) class of allowed Configurables to be assigned.
<handleType>: real python handle type (e.g. PublicToolHandle, PrivateToolHandle, ...)

Definition at line 366 of file PropertyProxy.py.

366 def __init__( self, descr, docString, default ):
367 """<descr>: the real property in the object instance (from __slots__)
368 <confTypeName>: string indicating the (base) class of allowed Configurables to be assigned.
369 <handleType>: real python handle type (e.g. PublicToolHandle, PrivateToolHandle, ...)
370 """
371 GaudiHandlePropertyProxyBase.__init__( self, descr, docString, default, type(default).handleType, GaudiHandleArray )
372 self.arrayType = type(default)
373
374

Member Function Documentation

◆ __delete__()

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

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.GaudiHandlePropertyProxyBase.__get__ ( self,
obj,
type = None )
inherited

Definition at line 199 of file PropertyProxy.py.

199 def __get__( self, obj, type = None ):
200 try:
201 return self.descr.__get__( obj, type )
202 except AttributeError:
203 # Get default
204 try:
205 default = obj.__class__.getDefaultProperty( self.descr.__name__ )
206 # if printing, just show the toolhandle. No need to auto-retrieve default configurable instance
207 if obj.isPrinting(): return default
208 default = self.convertDefaultToBeSet( obj, default )
209 # special case if default is auto-retrieved configurable instance
210 if self.isConfig(default):
211 if obj.isLocked():
212 # return a locked copy to produce error in case of setting any property
213 # rather then changing the value of the default
214 default = copy.deepcopy(default)
215 default.lock()
216 return default
217 else:
218 # Set to default configurable instance to allow MyTool.MySubTool.MyProperty = MyValue
219 self.__set__( obj, default )
220 elif isinstance(default,GaudiHandleArray):
221 if obj.isLocked():
222 # return a locked copy to produce error in case of setting any property
223 # rather then changing the value of the default
224 default = copy.deepcopy(default)
225 for c in default:
226 if self.isConfig(c):
227 c.lock()
228 return default
229 else:
230 # Set array to allow to add to default with syntax: MyTool.MyArray.append()
231 self.__set__( obj, default )
232 else:
233 return default
234 except AttributeError as e:
235 import traceback
236 traceback.print_exc()
237 # change type of exception to avoid false error message
238 raise RuntimeError("AttributeError(%s)" % e.args)
239
240 return self.descr.__get__( obj, type )
241
242

◆ __set__()

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

Definition at line 243 of file PropertyProxy.py.

243 def __set__( self, obj, value ):
244 # locked configurables can no longer be changed
245 if obj.isLocked():
246 raise RuntimeError(
247 'can not change property "%s" of locked configurable "%s"' %
248 (self.descr.__name__, obj.getJobOptName()) )
249
250 # allow a property to be set if we're in non-default mode, or if it
251 # simply hasn't been set before
252 if not obj._isInSetDefaults() or obj not in self.history:
253 value = self.convertValueToBeSet( obj, value )
254 # assign the value
255 self.descr.__set__( obj, value )
256 log.verbose( "Setting %s = %r", self.fullPropertyName( obj ), value )
257 self.history.setdefault( obj, [] ).append( value )
258
259

◆ checkType()

python.PropertyProxy.GaudiHandleArrayPropertyProxy.checkType ( self,
obj,
value )

Definition at line 375 of file PropertyProxy.py.

375 def checkType( self, obj, value ):
376 if not isinstance( value, list ) and not isinstance( value, self.arrayType ):
377 raise TypeError( "%s: Value %r is not a list nor a %s" % \
378 ( self.fullPropertyName(obj), value, self.arrayType.__name__ ) )
379
380

◆ convertDefaultToBeSet()

python.PropertyProxy.GaudiHandleArrayPropertyProxy.convertDefaultToBeSet ( self,
obj,
default )

Reimplemented from python.PropertyProxy.GaudiHandlePropertyProxyBase.

Definition at line 381 of file PropertyProxy.py.

381 def convertDefaultToBeSet( self, obj, default ):
382 self.checkType( obj, default )
383 newDefault = self.arrayType()
384 for d in default:
385 cd = GaudiHandlePropertyProxyBase.convertDefaultToBeSet( self, obj, d )
386 if cd: newDefault.append( cd )
387
388 return newDefault
389
390

◆ convertValueToBeSet()

python.PropertyProxy.GaudiHandleArrayPropertyProxy.convertValueToBeSet ( self,
obj,
value )

Reimplemented from python.PropertyProxy.GaudiHandlePropertyProxyBase.

Definition at line 391 of file PropertyProxy.py.

391 def convertValueToBeSet( self, obj, value ):
392 self.checkType( obj, value )
393 newValue = self.arrayType()
394 for v in value:
395 cv = GaudiHandlePropertyProxyBase.convertValueToBeSet( self, obj, v )
396 if cv: newValue.append( cv )
397
398 return newValue
399
400

◆ fullPropertyName()

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

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)
inherited

Definition at line 88 of file PropertyProxy.py.

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

◆ getDefaultConfigurable()

python.PropertyProxy.GaudiHandlePropertyProxyBase.getDefaultConfigurable ( self,
typeAndName,
requester )
inherited
Return the configurable instance corresponding to the toolhandle if possible.
Otherwise return None

Definition at line 270 of file PropertyProxy.py.

270 def getDefaultConfigurable(self,typeAndName,requester):
271 """Return the configurable instance corresponding to the toolhandle if possible.
272 Otherwise return None"""
273 # find the module
274 typeAndNameTuple = typeAndName.split('/')
275 confType = typeAndNameTuple[0]
276 confClass = ConfigurableDb.getConfigurable(confType)
277 # check the type of the configurable
278 if not derives_from(confClass,self._confTypeName):
279 log.error( "%s: Configurable %s is not a %s",
280 requester, confType, self._confTypeName )
281 return None
282 try:
283 confName = typeAndNameTuple[1]
284 except IndexError:
285 return confClass() # use default name
286 else:
287 return confClass(confName)
288
289

◆ isConfig()

python.PropertyProxy.GaudiHandlePropertyProxyBase.isConfig ( self,
value )
inherited
Check if <value> is a configurable of the correct type

Definition at line 265 of file PropertyProxy.py.

265 def isConfig(self,value):
266 """Check if <value> is a configurable of the correct type"""
267 return derives_from(value,self._confTypeName)
268
269

◆ isHandle()

python.PropertyProxy.GaudiHandlePropertyProxyBase.isHandle ( self,
value )
inherited
Check if <value> is a handle of the correct type

Definition at line 260 of file PropertyProxy.py.

260 def isHandle(self,value):
261 """Check if <value> is a handle of the correct type"""
262 return isinstance(value,self._handleType)
263
264

◆ setDefault()

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

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
privateinherited

Definition at line 86 of file PropertyProxy.py.

◆ __doc__

python.PropertyProxy.PropertyProxy.__doc__ = docString
privateinherited

Definition at line 81 of file PropertyProxy.py.

◆ _confTypeName

python.PropertyProxy.GaudiHandlePropertyProxyBase._confTypeName = 'Configurable' + handleType.componentType
protectedinherited

Definition at line 195 of file PropertyProxy.py.

◆ _handleType

python.PropertyProxy.GaudiHandlePropertyProxyBase._handleType = handleType
protectedinherited

Definition at line 194 of file PropertyProxy.py.

◆ arrayType

python.PropertyProxy.GaudiHandleArrayPropertyProxy.arrayType = type(default)

Definition at line 372 of file PropertyProxy.py.

◆ descr

python.PropertyProxy.PropertyProxy.descr = descr
inherited

Definition at line 79 of file PropertyProxy.py.

◆ history

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

Definition at line 78 of file PropertyProxy.py.

Property Documentation

◆ default

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

Definition at line 91 of file PropertyProxy.py.


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