Definition at line 981 of file Configurable.py.
def Configurable::ConfigurableService::__deepcopy__ | ( | self, | ||
memo | ||||
) |
def Configurable::ConfigurableService::copyChild | ( | self, | ||
child | ||||
) |
def Configurable::ConfigurableService::getHandle | ( | self | ) |
Definition at line 991 of file Configurable.py.
00991 : 00992 return iService( self._name ) 00993 def getGaudiType( self ):
def Configurable::ConfigurableService::getGaudiType | ( | self | ) |
Definition at line 994 of file Configurable.py.
00994 : 00995 return 'Service' 00996 def getGaudiHandle( self ):
def Configurable::ConfigurableService::getGaudiHandle | ( | self | ) |
Definition at line 997 of file Configurable.py.
00997 : 00998 return ServiceHandle( self.toStringProperty() ) 00999 def toStringProperty( self ):
def Configurable::ConfigurableService::toStringProperty | ( | self | ) |
Definition at line 1000 of file Configurable.py.
01000 : 01001 # called on conversion to a string property for the jocat 01002 return self.getName() 01003 01004 class ConfigurableAlgTool( Configurable ):
def Configurable::Configurable::__new__ | ( | cls, | ||
args, | ||||
kwargs | ||||
) | [inherited] |
To Gaudi, any object with the same type/name is the same object. Hence, this is mimicked in the configuration: instantiating a new Configurable of a type with the same name will return the same instance.
Definition at line 116 of file Configurable.py.
00119 : 00120 """To Gaudi, any object with the same type/name is the same object. Hence, 00121 this is mimicked in the configuration: instantiating a new Configurable 00122 of a type with the same name will return the same instance.""" 00123 00124 global log 00125 # try to get the name of the Configurable (having a name is compulsory) 00126 if 'name' in kwargs: 00127 # simple keyword (by far the easiest) 00128 name = kwargs[ 'name' ] 00129 elif 'name' in cls.__init__.func_code.co_varnames: 00130 # either positional in args, or default 00131 index = list(cls.__init__.func_code.co_varnames).index( 'name' ) 00132 try: 00133 # var names index is offset by one as __init__ is to be called with self 00134 name = args[ index - 1 ] 00135 except IndexError: 00136 # retrieve default value, then 00137 name = cls.__init__.func_defaults[ index - (len(args)+1) ] 00138 else: 00139 # positional index is assumed (will work most of the time) 00140 try: 00141 name = args[1] # '0' is for self 00142 except (IndexError,TypeError): 00143 raise TypeError( 'no "name" argument while instantiating "%s"' % cls.__name__ ) 00144 00145 argname = name 00146 if name == Configurable.DefaultName : 00147 if hasattr(cls, 'DefaultedName' ) : 00148 name = cls.DefaultedName 00149 else : 00150 name = cls.getType() 00151 elif not name or type(name) != str: 00152 # unnamed, highly specialized user code, etc. ... unacceptable 00153 raise TypeError( 'could not retrieve name from %s.__init__ arguments' % cls.__name__ ) 00154 00155 # Handle the case of global tools to prepend ToolSvc in the name. 00156 # This is needed for compatibility with old JobOptions files being read 00157 if issubclass( cls, ConfigurableAlgTool) and '.' not in name : 00158 name = 'ToolSvc.' + name 00159 00160 # close backdoor access to otherwise private subalgs/tools 00161 #PM if 0 <= name.find( '.' ): 00162 #PM # temp protection for old style types 00163 #PM from OldStyleConfig import GenericConfigurable 00164 #PM if not issubclass( cls, GenericConfigurable ): # except raised for new types only 00165 #PM raise NameError( '"%s": backdoor access to private configurables not allowed' % name ) 00166 00167 # ordinary recycle case 00168 if name in cls.configurables: 00169 conf = cls.configurables[ name ] 00170 if name != argname: # special case: user derived <-> real ... make same 00171 cls.configurables[ conf.getType() ] = conf 00172 #---PM: Initialize additional properties 00173 for n,v in kwargs.items(): 00174 setattr(conf, n, v) 00175 if not cls._configurationLocked and not "_enabled" in kwargs and isinstance(conf, ConfigurableUser): 00176 # Ensure that the ConfigurableUser gets enabled if nothing is 00177 # specified in the constructor. 00178 setattr(conf, "_enabled", True) 00179 return conf 00180 00181 # a couple of special cases (note that these cases don't mix) 00182 spos = name.find( '/' ) 00183 ti_name = None 00184 if spos < 0: 00185 ti_name = "%s/%s" % (name,name) 00186 if ti_name in cls.configurables: 00187 # support for old-style name as type/name lookup where name==type 00188 return cls.configurables[ ti_name ] 00189 00190 i_name = None 00191 if spos > 0: 00192 i_name = name[:spos] 00193 if i_name == name[spos+1:] and i_name in cls.configurables: 00194 # this is the opposite of the above special case 00195 return cls.configurables[ i_name ] 00196 00197 # the following is purely for debugging support and should realistically bomb 00198 conf = cls.allConfigurables.get( name, None ) or\ 00199 (spos < 0 and cls.allConfigurables.get( ti_name, None )) or\ 00200 (spos > 0 and i_name == name[spos+1:] and cls.allConfigurables.get( i_name, None )) 00201 if conf: # wrong type used? 00202 if conf.__class__ is ConfigurableGeneric : 00203 # If the instance found is ConfigurableGeneric then 00204 # we create a new one with the proper type and fill with 00205 # the contents of the generic one 00206 newconf = object.__new__( cls, *args, **kwargs ) 00207 cls.__init__( newconf, *args ) 00208 # initialize with the properties of generic configurable 00209 # (we map the names of the properties to lowercase versions because 00210 # old options are not case sensitive) 00211 names = {} 00212 for n in newconf.__slots__: 00213 names[n.lower()] = n 00214 for n in conf._properties: 00215 if names[n.lower()] != n: 00216 log.warning( "Option '%s' was used for %s, but the correct spelling is '%s'"%(n,name,names[n.lower()]) ) 00217 setattr(newconf, names[n.lower()], getattr( conf, n ) ) 00218 for n,v in kwargs.items(): 00219 setattr(newconf, n, v) 00220 cls.configurables[ name ] = newconf 00221 cls.allConfigurables[ name ] = newconf 00222 return newconf 00223 else : 00224 # will be an actual error in the future (now only report as such) 00225 log.error( 'attempt to redefine type of "%s" (was: %s, new: %s)%s', 00226 name, conf.__class__.__name__, cls.__name__, error_explanation ) 00227 # in the future: 00228 # return None # will bomb on use (or go unharmed on non-use) 00229 # for now, allow use through allConfigurables lookup 00230 #---PM: Initialize additional properties 00231 for n,v in kwargs.items(): 00232 setattr(conf, n, v) 00233 return conf 00234 00235 # still here: create a new instance and initialize it 00236 conf = object.__new__( cls, *args, **kwargs ) 00237 cls.__init__( conf, *args, **kwargs ) 00238 00239 # update normal, per-class cache 00240 cls.configurables[ name ] = conf 00241 00242 for base in cls.__bases__: 00243 if base.__name__ == 'ConfigurableService': 00244 cls.configurableServices[ name ] = conf 00245 00246 # update generics super-cache, if needed 00247 cls.allConfigurables[ name ] = conf 00248 #-->PM#if hasattr( cls, 'getType' ) and name.find('/') < 0: 00249 #-->PM# cls.allConfigurables[ cls.getType() + '/' + name ] = conf
def Configurable::Configurable::__init__ | ( | self, | ||
name = DefaultName | ||||
) | [inherited] |
Reimplemented in Configurable::ConfigurableGeneric, Configurable::ConfigurableAlgorithm, Configurable::ConfigurableAlgTool, and Configurable::ConfigurableAuditor.
Definition at line 250 of file Configurable.py.
00253 : 00254 # check class readiness, all required overloads should be there now 00255 klass = self.__class__ 00256 00257 # this is an abstract class 00258 if klass == Configurable: 00259 raise TypeError, "%s is an ABC and can not be instantiated" % str(Configurable) 00260 00261 # the following methods require overloading 00262 #NOT YET meths = { 'getServices' : 1, # retrieve list of services to configure 00263 meths = { 'getDlls' : 1, # provide list of Dlls to load 00264 'getGaudiType' : 1, # return string describing component class 00265 'getHandle' : 1 } # provide access to C++ side component instance 00266 # 'getType' : 1 } # return the type of the actual C++ component 00267 00268 for meth, nArgs in meths.items(): 00269 try: 00270 f = getattr( klass, meth ).im_func 00271 except AttributeError: 00272 raise NotImplementedError, "%s is missing in class %s" % (meth,str(klass)) 00273 00274 # in addition, verify the number of arguments w/o defaults 00275 nargcount = f.func_code.co_argcount 00276 ndefaults = f.func_defaults and len(f.func_defaults) or 0 00277 if not nargcount - ndefaults <= nArgs <= nargcount: 00278 raise TypeError, "%s.%s requires exactly %d arguments" % (klass,meth,nArgs) 00279 00280 # for using this Configurable as a (Gaudi) sequence 00281 self.__children = [] 00282 self.__tools = {} 00283 00284 # know who we are 00285 if name == Configurable.DefaultName : 00286 if hasattr(self.__class__, 'DefaultedName' ) : 00287 self._name = self.__class__.DefaultedName 00288 else : 00289 self._name = self.getType() 00290 else : 00291 self._name = name 00292 00293 # set to True when collecting defaults, False otherwise 00294 self._inSetDefaults = False 00295 00296 # for later, in case __init__ itself is overridden 00297 self._initok = True 00298 00299 # for debugging purposes (temporary) self._setupok = False
def Configurable::Configurable::__getstate__ | ( | self | ) | [inherited] |
Definition at line 300 of file Configurable.py.
00303 : 00304 dict = {} 00305 for name, proxy in self._properties.items(): 00306 try: 00307 dict[ name ] = proxy.__get__( self ) 00308 except AttributeError: 00309 pass 00310 00311 dict[ '_Configurable__children' ] = self.__children 00312 dict[ '_Configurable__tools' ] = self.__tools dict[ '_name' ] = self._name
def Configurable::Configurable::__getnewargs__ | ( | self | ) | [inherited] |
def Configurable::Configurable::__setstate__ | ( | self, | ||
dict | ||||
) | [inherited] |
Definition at line 316 of file Configurable.py.
00316 : 00317 return (self._name,) 00318 00319 def __setstate__ ( self, dict ): 00320 self._initok = True 00321 for n, v in dict.items(): 00322 setattr (self, n, v) return
def Configurable::Configurable::__len__ | ( | self | ) | [inherited] |
def Configurable::Configurable::__iter__ | ( | self | ) | [inherited] |
Definition at line 326 of file Configurable.py.
00326 : 00327 return len( self.__children ) 00328 00329 def __iter__( self ): return iter( self.__children )
def Configurable::Configurable::__iadd__ | ( | self, | ||
configs, | ||||
descr = None | ||||
) | [inherited] |
Definition at line 346 of file Configurable.py.
00349 : 00350 if not type(configs) in (list,tuple): 00351 configs = ( configs, ) 00352 00353 joname = self.getJobOptName() 00354 00355 for cfg in configs: 00356 # prevent type mismatches 00357 if not isinstance( cfg, Configurable ): 00358 raise TypeError( "'%s' is not a Configurable" % str(cfg) ) 00359 00360 cc = self.copyChildAndSetParent( cfg, joname ) 00361 00362 # filters dupes; usually "ok" (backdoor should catch them) 00363 ccjo = cc.getJobOptName() 00364 for c in self.__children: 00365 if c.getJobOptName() == ccjo: 00366 log.error( 'attempt to add a duplicate ... dupe ignored%s', error_explanation ) 00367 break 00368 else: 00369 self.__children.append( cc ) 00370 00371 try: 00372 if descr: # support for tool properties 00373 descr.__set__( self, cc ) 00374 else: 00375 setattr( self, cc.getName(), cc ) 00376 except AttributeError: 00377 pass # to allow free addition of tools/subalgorithms
def Configurable::Configurable::__getattr__ | ( | self, | ||
attr | ||||
) | [inherited] |
Definition at line 378 of file Configurable.py.
00381 : # until ToolProperties exist ... 00382 00383 if attr in self.__tools : return self.__tools[attr] 00384 00385 for c in self.__children: 00386 if c.getName() == attr: 00387 return c
def Configurable::Configurable::__setattr__ | ( | self, | ||
name, | ||||
value | ||||
) | [inherited] |
Reimplemented in Configurable::ConfigurableGeneric.
Definition at line 388 of file Configurable.py.
00391 : 00392 if self._configurationLocked: 00393 raise RuntimeError("%s: Configuration cannot be modified after the ApplicationMgr has been started."%self.name()) 00394 try : 00395 super( Configurable, self ).__setattr__( name, value ) 00396 except AttributeError: raise AttributeError( "Configurable '%s' does not have property '%s'."
def Configurable::Configurable::__delattr__ | ( | self, | ||
attr | ||||
) | [inherited] |
Definition at line 397 of file Configurable.py.
00400 : 00401 # remove as property, otherwise try as child 00402 try: 00403 # remove history etc., then reset to default (in case set before) 00404 prop = self._properties[ attr ] 00405 prop.__delete__( self ) 00406 prop.__set__( self, prop.default ) 00407 return # reaches here? was property: done now 00408 except KeyError: 00409 pass 00410 # otherwise, remove the private tool 00411 if attr in self.__tools : 00412 del self.__tools[attr] 00413 00414 # otherwise, remove child, if one is so named 00415 for c in self.__children: 00416 if c.getName() == attr: 00417 self.__children.remove( c ) 00418 00419 # potentially, there are left over caches (certain user derived classes) 00420 try: 00421 del self.__dict__[ attr ] except (AttributeError,KeyError):
def Configurable::Configurable::__nonzero__ | ( | self | ) | [inherited] |
Definition at line 422 of file Configurable.py.
00422 : 00423 pass 00424 00425 def __nonzero__(self): return True
def Configurable::Configurable::remove | ( | self, | ||
items | ||||
) | [inherited] |
def Configurable::Configurable::removeAll | ( | self | ) | [inherited] |
def Configurable::Configurable::setParent | ( | self, | ||
parentName | ||||
) | [inherited] |
def Configurable::Configurable::getParent | ( | self | ) | [inherited] |
def Configurable::Configurable::hasParent | ( | self, | ||
parent | ||||
) | [inherited] |
def Configurable::Configurable::copyChildAndSetParent | ( | self, | ||
cfg, | ||||
parent | ||||
) | [inherited] |
Definition at line 448 of file Configurable.py.
00448 : 00449 return False 00450 00451 def copyChildAndSetParent(self,cfg,parent): 00452 cc = self.copyChild( cfg ) 00453 00454 if hasattr( cc, 'setParent' ) and parent: 00455 try: 00456 cc.setParent( parent ) 00457 except RuntimeError, e: 00458 # temporary backdoor resolution for compatibility 00459 log.error( str(e) + '%s', error_explanation ) 00460 ccbd = cc.configurables[ cc.getJobOptName() ] 00461 00462 # merge properties, new over pre-existing 00463 for proxy in self._properties.values(): 00464 if proxy.history.has_key( cc ): 00465 proxy.__set__( ccbd, proxy.__get__( cc ) ) 00466 00467 # consolidate cc = ccbd
def Configurable::Configurable::getChildren | ( | self | ) | [inherited] |
def Configurable::Configurable::getTools | ( | self | ) | [inherited] |
Definition at line 471 of file Configurable.py.
00471 : 00472 return self.__children[:] # read only 00473 def getTools( self ):
def Configurable::Configurable::children | ( | self | ) | [inherited] |
Definition at line 474 of file Configurable.py.
00474 : 00475 return self.__tools.values() # read only 00476 00477 def children( self ): 00478 log.error( "children() is deprecated, use getChildren() instead for consistency" ) 00479 log.error( "getChildren() returns a copy; to add a child, use 'parent += child'%s", error_explanation )
def Configurable::Configurable::getAllChildren | ( | self | ) | [inherited] |
Get all (private) configurable children, both explicit ones (added with +=) and the ones in the private GaudiHandle properties
Definition at line 480 of file Configurable.py.
00483 : 00484 """Get all (private) configurable children, both explicit ones (added with +=) 00485 and the ones in the private GaudiHandle properties""" 00486 childs = [] 00487 # add private configurable properties (also inside handles) 00488 for proxy in self._properties.values(): 00489 try: 00490 c = proxy.__get__( self ) 00491 except AttributeError: 00492 pass 00493 else: 00494 if isinstance(c,Configurable) and not c.isPublic(): 00495 childs.append(c) 00496 elif isinstance(c,GaudiHandle): 00497 try: 00498 conf = c.configurable 00499 except AttributeError: 00500 pass 00501 else: 00502 if not conf.isPublic(): 00503 childs.append(conf) 00504 elif isinstance(c,GaudiHandleArray): 00505 # only setup private arrays 00506 if not c.isPublic(): 00507 for ci in c: 00508 if isinstance(ci,Configurable): 00509 childs.append(ci) 00510 else: 00511 try: 00512 conf = ci.configurable 00513 except AttributeError: 00514 pass 00515 else: 00516 childs.append(conf) 00517 00518 # add explicit children childs += self.__children
def Configurable::Configurable::getSequence | ( | self | ) | [inherited] |
def Configurable::Configurable::setup | ( | self | ) | [inherited] |
Definition at line 525 of file Configurable.py.
00528 : 00529 # make sure base class init has been called 00530 if not hasattr(self,'_initok') or not self._initok: 00531 # could check more, but this is the only explanation 00532 raise TypeError, \ 00533 "Configurable.__init__ not called in %s override" % self.__class__.__name__ 00534 00535 # log.debug("calling setup() on " + self.getFullJobOptName()) 00536 00537 # setup self: this collects all values on the python side 00538 self.__setupServices() 00539 self.__setupDlls() 00540 self.__setupDefaults() 00541 00542 # setup children 00543 for c in self.getAllChildren(): 00544 c.setup() 00545 00546 # now get handle to work with for moving properties into the catalogue 00547 handle = self.getHandle() 00548 if not handle: 00549 log.debug( 'no handle for %s: not transporting properties', self._name ) 00550 return # allowed, done early 00551 00552 # pass final set of properties on to handle on the C++ side or JobOptSvc 00553 for name in self._properties.keys(): 00554 if hasattr( self, name ): # means property has python-side value/default 00555 setattr( handle, name, getattr(self,name) ) 00556 # for debugging purposes
def Configurable::Configurable::getProperties | ( | self | ) | [inherited] |
Definition at line 557 of file Configurable.py.
00560 : 00561 props = {} 00562 for name, proxy in self._properties.items(): 00563 try: 00564 props[ name ] = proxy.__get__( self ) 00565 except AttributeError: 00566 props[ name ] = Configurable.propertyNoValue
def Configurable::Configurable::getValuedProperties | ( | self | ) | [inherited] |
Definition at line 567 of file Configurable.py.
00570 : 00571 props = {} 00572 for name, proxy in self._properties.items(): 00573 if self.isPropertySet(name): 00574 value = proxy.__get__( self ) 00575 if hasattr(value, 'getFullName') : 00576 value = value.getFullName() 00577 elif type(value) in [list, tuple]: 00578 new_value = [] 00579 for i in value: 00580 if hasattr(i, 'getFullName'): 00581 new_value.append(i.getFullName()) 00582 else: 00583 new_value.append(i) 00584 value = type(value)(new_value) 00585 elif type(value) is dict: 00586 new_value = {} 00587 for i in value: 00588 if hasattr(value[i], 'getFullName'): 00589 new_value[i] = value[i].getFullName() 00590 else: 00591 new_value[i] = value[i] 00592 value = new_value 00593 props[ name ] = value
def Configurable::Configurable::properties | ( | self | ) | [inherited] |
def Configurable::Configurable::getDefaultProperties | ( | cls | ) | [inherited] |
Definition at line 598 of file Configurable.py.
00601 : 00602 class collector: 00603 pass 00604 00605 # user provided defaults 00606 c = collector() 00607 cls.setDefaults( c ) 00608 00609 # defaults from C++ 00610 for k,v in cls._properties.items(): 00611 if not k in c.__dict__ and hasattr( v, 'default' ): 00612 c.__dict__[ k ] = v.default 00613 return c.__dict__
def Configurable::Configurable::getDefaultProperty | ( | cls, | ||
name | ||||
) | [inherited] |
Definition at line 614 of file Configurable.py.
00617 : 00618 class collector: 00619 pass 00620 00621 # user provided defaults 00622 c = collector() 00623 cls.setDefaults( c ) 00624 00625 if name in c.__dict__: 00626 return c.__dict__[ name ] 00627 00628 # defaults from C++ 00629 try: 00630 v = cls._properties[name] 00631 if hasattr( v, 'default' ): 00632 return v.default 00633 except KeyError: 00634 pass
def Configurable::Configurable::getProp | ( | self, | ||
name | ||||
) | [inherited] |
Returns the value of the given property.
Definition at line 635 of file Configurable.py.
00638 : 00639 """Returns the value of the given property. 00640 """ 00641 if hasattr(self, name): 00642 return getattr(self, name) else:
def Configurable::Configurable::setProp | ( | self, | ||
name, | ||||
value | ||||
) | [inherited] |
Set the value of a given property
Definition at line 643 of file Configurable.py.
00643 : 00644 return self.getDefaultProperties()[name] 00645 00646 def setProp(self, name, value): 00647 """Set the value of a given property """
def Configurable::Configurable::isPropertySet | ( | self, | ||
name | ||||
) | [inherited] |
Tell if the property 'name' has been set or not. Because of a problem with list and dictionary properties, in those cases if the value is equal to the default, the property is considered as not set.
Definition at line 648 of file Configurable.py.
00651 : 00652 """Tell if the property 'name' has been set or not. 00653 00654 Because of a problem with list and dictionary properties, in those cases 00655 if the value is equal to the default, the property is considered as not 00656 set. 00657 """ 00658 if not hasattr(self, name): 00659 return False 00660 else: 00661 try: 00662 default = self.getDefaultProperties()[name] 00663 if isinstance(default, (list, dict)): 00664 value = getattr(self, name) 00665 return value != default 00666 except KeyError: pass # no default found
def Configurable::Configurable::getType | ( | cls | ) | [inherited] |
def Configurable::Configurable::getName | ( | self | ) | [inherited] |
def Configurable::Configurable::name | ( | self | ) | [inherited] |
def Configurable::Configurable::getJobOptName | ( | self | ) | [inherited] |
Reimplemented in Configurable::ConfigurableGeneric, Configurable::ConfigurableAlgorithm, Configurable::ConfigurableAlgTool, and Configurable::ConfigurableAuditor.
Definition at line 676 of file Configurable.py.
00676 : 00677 return self.getName() 00678 def getJobOptName( self ): # full hierachical name
def Configurable::Configurable::isPublic | ( | self | ) | [inherited] |
def Configurable::Configurable::jobOptName | ( | self | ) | [inherited] |
Definition at line 683 of file Configurable.py.
00686 : 00687 log.error( "jobOptName() is deprecated, use getJobOptName() instead for consistency%s", error_explanation )
def Configurable::Configurable::getFullName | ( | self | ) | [inherited] |
def Configurable::Configurable::getFullJobOptName | ( | self | ) | [inherited] |
Definition at line 691 of file Configurable.py.
00691 : 00692 return str( self.getType() + '/' + self.getName() ) 00693 def getFullJobOptName( self ):
def Configurable::Configurable::getPrintTitle | ( | self | ) | [inherited] |
Reimplemented in Configurable::ConfigurableAlgTool.
Definition at line 694 of file Configurable.py.
00694 : 00695 return "%s/%s" % (self.getType(),self.getJobOptName() or self.getName()) 00696 def getPrintTitle(self):
def Configurable::Configurable::getTitleName | ( | self | ) | [inherited] |
Definition at line 697 of file Configurable.py.
00697 : 00698 return self.getGaudiType() + ' ' + self.getTitleName() 00699 00700 def getTitleName( self ): 00701 if log.isEnabledFor( logging.DEBUG ): 00702 return self.getFullJobOptName() else:
def Configurable::Configurable::setDefaults | ( | cls, | ||
handle | ||||
) | [inherited] |
Definition at line 703 of file Configurable.py.
00703 : 00704 return self.getFullName() 00705 def setDefaults( cls, handle ):
def Configurable::Configurable::clone | ( | self, | ||
name = None , |
||||
kwargs | ||||
) | [inherited] |
Definition at line 706 of file Configurable.py.
00706 : 00707 pass 00708 00709 def clone( self, name = None, **kwargs ) : 00710 if not name : 00711 if hasattr(self, 'DefaultedName' ) : name = self.DefaultedName 00712 else : name = self.getType() 00713 00714 newconf = Configurable.__new__( self.__class__, name ) 00715 self.__class__.__init__( newconf, name ) 00716 00717 for proxy in self._properties.values(): 00718 try : 00719 value = proxy.__get__( self ) 00720 if type(value) in [ str, list, dict, tuple ]: 00721 # clone the values of the properties for basic types 00722 value = type(value)(value) 00723 proxy.__set__( newconf, value ) 00724 except AttributeError: 00725 pass 00726 00727 for c in self.__children: 00728 newconf += c # processes proper copy semantics 00729 00730 for n , t in self.__tools.items(): 00731 newconf.addTool(t, n) 00732 00733 for name, value in kwargs.items(): 00734 setattr(newconf, name, value)
def Configurable::Configurable::splitName | ( | self | ) | [inherited] |
Definition at line 735 of file Configurable.py.
00738 : 00739 fullname = self.getName() 00740 dot = fullname.find('.') 00741 if dot != -1 : 00742 parentname = fullname[:dot] 00743 longname = fullname[dot+1:] 00744 else : 00745 parentname = '' 00746 longname = fullname 00747 dot = longname.find('.') 00748 if dot != -1 : 00749 name = longname[:dot] 00750 else : name = longname
def Configurable::Configurable::addTool | ( | self, | ||
tool, | ||||
name = None | ||||
) | [inherited] |
Definition at line 751 of file Configurable.py.
00754 : 00755 if isclass(tool) and issubclass(tool, ConfigurableAlgTool): 00756 if name is None: 00757 name = tool.__name__ 00758 priv_tool = tool( self.getName()+ '.' + name ) 00759 elif isinstance(tool, ConfigurableAlgTool): 00760 if name is None: 00761 name = tool.splitName()[1] 00762 priv_tool = tool.clone( self.getName()+ '.' + name ) 00763 else: 00764 if isclass(tool): 00765 classname = tool.__name__ 00766 else: 00767 classname = type(tool).__name__ 00768 raise TypeError, "addTool requires AlgTool configurable. Got %s type" % classname 00769 self.__tools[name] = priv_tool 00770 if name in self.__slots__: # this is to avoid that the property hides the tool
def Configurable::Configurable::__repr__ | ( | self | ) | [inherited] |
Definition at line 823 of file Configurable.py.
00826 : return '<%s at %s>' % (self.getFullJobOptName(),hex(id(self)))
def Configurable::Configurable::__str__ | ( | self, | ||
indent = 0 , |
||||
headerLastIndentUnit = indentUnit | ||||
) | [inherited] |
Definition at line 826 of file Configurable.py.
00826 : 00827 return '<%s at %s>' % (self.getFullJobOptName(),hex(id(self))) 00828 00829 def __str__( self, indent = 0, headerLastIndentUnit=indentUnit ): 00830 global log # to print some info depending on output level 00831 indentStr = indent*Configurable.indentUnit 00832 # print header 00833 title = self.getPrintTitle() 00834 # print line to easily see start-of-configurable 00835 if indent > 0: 00836 headerIndent = (indent-1)*Configurable.indentUnit + headerLastIndentUnit 00837 else: 00838 headerIndent = '' 00839 rep = Configurable._printHeader( headerIndent, title ) 00840 rep += os.linesep 00841 # print own properties 00842 props = self.getProperties() 00843 defs = self.getDefaultProperties() 00844 if not props: 00845 rep += indentStr + '|-<no properties>' + os.linesep 00846 else: 00847 # get property name with 00848 nameWidth = 0 00849 for p in props.keys(): 00850 nameWidth=max(nameWidth,len(p)) 00851 for p, v in props.items(): 00852 # start with indent and property name 00853 prefix = indentStr + '|-%-*s' % (nameWidth,p) 00854 # add memory address for debugging (not for defaults) 00855 if log.isEnabledFor( logging.DEBUG ): 00856 if v != Configurable.propertyNoValue: 00857 address = ' @%11s' % hex(id(v)) 00858 else: 00859 address = 13*' ' 00860 prefix += address 00861 # add value and default 00862 default = defs.get(p) 00863 if v == Configurable.propertyNoValue: 00864 # show default value as value, and no extra 'default' 00865 strVal = repr(default) 00866 strDef = None 00867 else: 00868 # convert configurable to handle 00869 if hasattr(v,"getGaudiHandle"): 00870 vv = v.getGaudiHandle() 00871 else: 00872 vv = v 00873 if isinstance(vv,GaudiHandle) or isinstance(vv,GaudiHandleArray): 00874 strVal = repr(vv) 00875 if hasattr(default,"toStringProperty"): # the default may not be a GaudiHandle (?) 00876 strDef = repr(default.toStringProperty()) 00877 else: 00878 strDef = repr(default) 00879 if strDef == repr(vv.toStringProperty()): 00880 strDef = None 00881 else: 00882 strVal = repr(vv) 00883 strDef = repr(default) 00884 # add the value 00885 line = prefix + ' = ' + strVal 00886 # add default if present 00887 if strDef is not None: 00888 # put default on new line if too big 00889 if len(line) + len(strDef) > Configurable.printHeaderWidth: 00890 line += os.linesep + indentStr + '| ' + (len(prefix)-len(indentStr)-3)*' ' 00891 line += ' (default: %s)' % (strDef,) # add the line to the total string
dictionary Configurable::ConfigurableService::__slots__ [static, private] |
Initial value:
{ 'OutputLevel' : 0, \ 'AuditServices' : 0, 'AuditInitialize' : 0, 'AuditFinalize' : 0 }
Reimplemented from Configurable::Configurable.
Definition at line 982 of file Configurable.py.
string Configurable::Configurable::propertyNoValue = '<no value>' [static, inherited] |
Definition at line 94 of file Configurable.py.
string Configurable::Configurable::indentUnit = '| ' [static, inherited] |
Definition at line 95 of file Configurable.py.
int Configurable::Configurable::printHeaderWidth = 100 [static, inherited] |
Definition at line 96 of file Configurable.py.
int Configurable::Configurable::printHeaderPre = 5 [static, inherited] |
Definition at line 97 of file Configurable.py.
dictionary Configurable::Configurable::allConfigurables = {} [static, inherited] |
Definition at line 110 of file Configurable.py.
dictionary Configurable::Configurable::configurableServices = {} [static, inherited] |
Definition at line 111 of file Configurable.py.