|
| def | __init__ (self, descr, docString, default, handleType, allowedType) |
| |
| def | __get__ (self, obj, type=None) |
| |
| def | __set__ (self, obj, value) |
| |
| def | isHandle (self, value) |
| |
| def | isConfig (self, value) |
| |
| def | getDefaultConfigurable (self, typeAndName, requester) |
| |
| def | convertDefaultToBeSet (self, obj, default) |
| |
| def | convertValueToBeSet (self, obj, value) |
| |
| def | __init__ (self, descr, docString=None, default=None) |
| |
| def | setDefault (self, value) |
| |
| def | getDefault (self) |
| |
| def | fullPropertyName (self, obj) |
| |
| def | __delete__ (self, obj) |
| |
A class with some utilities for GaudiHandles and GaudiHandleArrays
Definition at line 183 of file PropertyProxy.py.
◆ __init__()
| def GaudiKernel.PropertyProxy.GaudiHandlePropertyProxyBase.__init__ |
( |
|
self, |
|
|
|
descr, |
|
|
|
docString, |
|
|
|
default, |
|
|
|
handleType, |
|
|
|
allowedType |
|
) |
| |
<descr>: the real property in the object instance (from __slots__)
<docString>: the documentation string of this property
<default>: default value from C++ (via python generated by genconf)
<handleType>: real python handle type (e.g. PublicToolHandle, PrivateToolHandle, ...)
<allowedType>: allowed instance type for default
Definition at line 186 of file PropertyProxy.py.
186 def __init__(self, descr, docString, default, handleType, allowedType):
187 """<descr>: the real property in the object instance (from __slots__)
188 <docString>: the documentation string of this property
189 <default>: default value from C++ (via python generated by genconf)
190 <handleType>: real python handle type (e.g. PublicToolHandle, PrivateToolHandle, ...)
191 <allowedType>: allowed instance type for default
194 if not isinstance(default, allowedType):
196 "%s: %s default: %r is not a %s"
199 self.__class__.__name__,
201 allowedType.__name__,
204 PropertyProxy.__init__(self, descr, docString, default)
205 self._handleType = handleType
206 self._confTypeName =
"Configurable" + handleType.componentType
◆ __get__()
| def GaudiKernel.PropertyProxy.GaudiHandlePropertyProxyBase.__get__ |
( |
|
self, |
|
|
|
obj, |
|
|
|
type = None |
|
) |
| |
Reimplemented from GaudiKernel.PropertyProxy.PropertyProxy.
Definition at line 210 of file PropertyProxy.py.
210 def __get__(self, obj, type=None):
212 return self.descr.__get__(obj, type)
213 except AttributeError:
216 default = obj.__class__.getDefaultProperty(self.descr.__name__)
217 default = self.convertDefaultToBeSet(obj, default)
219 self.__set__(obj, default)
220 except AttributeError
as e:
222 raise RuntimeError(*e.args)
224 return self.descr.__get__(obj, type)
◆ __set__()
| def GaudiKernel.PropertyProxy.GaudiHandlePropertyProxyBase.__set__ |
( |
|
self, |
|
|
|
obj, |
|
|
|
value |
|
) |
| |
Reimplemented from GaudiKernel.PropertyProxy.PropertyProxy.
Definition at line 226 of file PropertyProxy.py.
226 def __set__(self, obj, value):
229 if not obj._isInSetDefaults()
or not obj
in self.history:
230 value = self.convertValueToBeSet(obj, value)
232 self.descr.__set__(obj, value)
233 log.debug(
"Setting %s = %r", self.fullPropertyName(obj), value)
234 self.history.setdefault(obj, []).append(value)
◆ convertDefaultToBeSet()
| def GaudiKernel.PropertyProxy.GaudiHandlePropertyProxyBase.convertDefaultToBeSet |
( |
|
self, |
|
|
|
obj, |
|
|
|
default |
|
) |
| |
Reimplemented in GaudiKernel.PropertyProxy.GaudiHandleArrayPropertyProxy.
Definition at line 268 of file PropertyProxy.py.
268 def convertDefaultToBeSet(self, obj, default):
270 isString =
type(default) == str
271 if not isString
and self.isConfig(default):
274 elif isString
or self.isHandle(default):
277 typeAndName = default
278 default = self._handleType(typeAndName)
280 typeAndName = default.typeAndName
281 if not self._handleType.isPublic:
287 if "/" in typeAndName:
288 typeAndName = typeAndName.replace(
"/",
"/{}.".
format(obj.name()), 1)
290 typeAndName =
"{0}/{1}.{0}".
format(typeAndName, obj.name())
292 conf = self.getDefaultConfigurable(
293 typeAndName, self.fullPropertyName(obj)
297 except AttributeError
as e:
299 raise RuntimeError(*e.args)
302 "%s: Default configurable for class %s not found in ConfigurableDb.CfgDb"
303 % (self.fullPropertyName(obj), default.getType())
308 "%s: default value %r is not of type %s or %s"
310 self.fullPropertyName(obj),
313 self._handleType.__name__,
◆ convertValueToBeSet()
| def GaudiKernel.PropertyProxy.GaudiHandlePropertyProxyBase.convertValueToBeSet |
( |
|
self, |
|
|
|
obj, |
|
|
|
value |
|
) |
| |
Reimplemented in GaudiKernel.PropertyProxy.GaudiHandleArrayPropertyProxy.
Definition at line 319 of file PropertyProxy.py.
319 def convertValueToBeSet(self, obj, value):
322 isString =
type(value) == str
325 return self._handleType(value)
326 elif self.isHandle(value):
328 return self._handleType(value.toStringProperty())
329 elif self.isConfig(value):
330 if self._handleType.isPublic:
333 if not value.isInToolSvc():
335 "You may need to add jobOptions lines something like:"
337 +
"from AthenaCommon.AppMgr import ToolSvc"
341 if value.getName() == value.getType():
342 suggestion +=
"%s()" % value.__class__.__name__
344 suggestion +=
"%s(%r)" % (
345 value.__class__.__name__,
349 self.fullPropertyName(obj)
350 +
": Public tool %s is not yet in ToolSvc. %s"
351 % (value.getJobOptName(), suggestion)
354 return self._handleType(value.toStringProperty())
355 elif value.hasParent(obj.getJobOptName()):
360 value = obj.copyChildAndSetParent(value, obj.getJobOptName())
362 obj.allConfigurables[value.name()] = value
366 "Property %s value %r is not a %s nor a %s nor a string"
368 self.fullPropertyName(obj),
371 self._handleType.__name__,
◆ getDefaultConfigurable()
| def GaudiKernel.PropertyProxy.GaudiHandlePropertyProxyBase.getDefaultConfigurable |
( |
|
self, |
|
|
|
typeAndName, |
|
|
|
requester |
|
) |
| |
Return the configurable instance corresponding to the toolhandle if possible.
Otherwise return None
Definition at line 244 of file PropertyProxy.py.
244 def getDefaultConfigurable(self, typeAndName, requester):
245 """Return the configurable instance corresponding to the toolhandle if possible.
246 Otherwise return None"""
249 typeAndNameTuple = typeAndName.split(
"/")
250 confType = typeAndNameTuple[0]
251 confClass = ConfigurableDb.getConfigurable(confType)
255 "%s: Configurable %s is not a %s",
262 confName = typeAndNameTuple[1]
266 return confClass(confName)
◆ isConfig()
| def GaudiKernel.PropertyProxy.GaudiHandlePropertyProxyBase.isConfig |
( |
|
self, |
|
|
|
value |
|
) |
| |
Check if <value> is a configurable of the correct type
Definition at line 240 of file PropertyProxy.py.
240 def isConfig(self, value):
241 """Check if <value> is a configurable of the correct type"""
◆ isHandle()
| def GaudiKernel.PropertyProxy.GaudiHandlePropertyProxyBase.isHandle |
( |
|
self, |
|
|
|
value |
|
) |
| |
Check if <value> is a handle of the correct type
Definition at line 236 of file PropertyProxy.py.
236 def isHandle(self, value):
237 """Check if <value> is a handle of the correct type"""
238 return isinstance(value, self._handleType)
◆ _confTypeName
| GaudiKernel.PropertyProxy.GaudiHandlePropertyProxyBase._confTypeName |
|
private |
◆ _handleType
| GaudiKernel.PropertyProxy.GaudiHandlePropertyProxyBase._handleType |
|
private |
The documentation for this class was generated from the following file: