ATLAS Offline Software
Public Member Functions | Public Attributes | Properties | Private Attributes | List of all members
python.PropertyProxy.GaudiHandleArrayPropertyProxy Class Reference
Inheritance diagram for python.PropertyProxy.GaudiHandleArrayPropertyProxy:
Collaboration diagram for python.PropertyProxy.GaudiHandleArrayPropertyProxy:

Public Member Functions

def __init__ (self, descr, docString, default)
 
def checkType (self, obj, value)
 
def convertDefaultToBeSet (self, obj, default)
 
def convertValueToBeSet (self, obj, value)
 
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 setDefault (self, value)
 
def getDefault (self)
 
def fullPropertyName (self, obj)
 
def __delete__ (self, obj)
 

Public Attributes

 arrayType
 
 history
 
 descr
 

Properties

 default = property( getDefault, setDefault )
 

Private Attributes

 _handleType
 
 _confTypeName
 
 __doc__
 
 __default
 

Detailed Description

Definition at line 366 of file PropertyProxy.py.

Constructor & Destructor Documentation

◆ __init__()

def 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, ...)

Reimplemented from python.PropertyProxy.PropertyProxy.

Definition at line 367 of file PropertyProxy.py.

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

Member Function Documentation

◆ __delete__()

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

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

Reimplemented from python.PropertyProxy.PropertyProxy.

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__()

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

Reimplemented from python.PropertyProxy.PropertyProxy.

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

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

Definition at line 376 of file PropertyProxy.py.

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

◆ convertDefaultToBeSet()

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

Reimplemented from python.PropertyProxy.GaudiHandlePropertyProxyBase.

Definition at line 382 of file PropertyProxy.py.

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

◆ convertValueToBeSet()

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

Reimplemented from python.PropertyProxy.GaudiHandlePropertyProxyBase.

Definition at line 392 of file PropertyProxy.py.

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

◆ fullPropertyName()

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

def python.PropertyProxy.PropertyProxy.getDefault (   self)
inherited

Definition at line 88 of file PropertyProxy.py.

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

◆ getDefaultConfigurable()

def 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  global log
274  # find the module
275  typeAndNameTuple = typeAndName.split('/')
276  confType = typeAndNameTuple[0]
277  confClass = ConfigurableDb.getConfigurable(confType)
278  # check the type of the configurable
279  if not derives_from(confClass,self._confTypeName):
280  log.error( "%s: Configurable %s is not a %s",
281  requester, confType, self._confTypeName )
282  return None
283  try:
284  confName = typeAndNameTuple[1]
285  except IndexError:
286  return confClass() # use default name
287  else:
288  return confClass(confName)
289 
290 

◆ isConfig()

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

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

def 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
privateinherited

Definition at line 86 of file PropertyProxy.py.

◆ __doc__

python.PropertyProxy.PropertyProxy.__doc__
privateinherited

Definition at line 81 of file PropertyProxy.py.

◆ _confTypeName

python.PropertyProxy.GaudiHandlePropertyProxyBase._confTypeName
privateinherited

Definition at line 195 of file PropertyProxy.py.

◆ _handleType

python.PropertyProxy.GaudiHandlePropertyProxyBase._handleType
privateinherited

Definition at line 194 of file PropertyProxy.py.

◆ arrayType

python.PropertyProxy.GaudiHandleArrayPropertyProxy.arrayType

Definition at line 373 of file PropertyProxy.py.

◆ descr

python.PropertyProxy.PropertyProxy.descr
inherited

Definition at line 79 of file PropertyProxy.py.

◆ history

python.PropertyProxy.PropertyProxy.history
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:
python.PropertyProxy.derives_from
def derives_from(derived, base)
Definition: PropertyProxy.py:27
dumpHVPathFromNtuple.append
bool append
Definition: dumpHVPathFromNtuple.py:91
python.processes.powheg.ZZ.ZZ.__init__
def __init__(self, base_directory, **kwargs)
Constructor: all process options are set here.
Definition: ZZ.py:18
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78