3 from AthenaCommon.Logging
import logging
4 from AthenaCommon.CFElements
import isSequence
6 from GaudiKernel.GaudiHandles
import PrivateToolHandle, PrivateToolHandleArray
8 msg = logging.getLogger(
'PropSetterProxy')
19 if name.startswith(
"_PropSetterProxy"):
20 return super(PropSetterProxy, self).
__setattr__(name, value)
22 if name !=
"OutputLevel":
23 msg.error(
"The foreach_component is a debugging feature and should not be used in production jobs, remove it before committing to the repository, proceeding to set the properties now" )
26 for component_path, component
in PropSetterProxy.__compPaths.items():
27 if fnmatch.fnmatch( component_path, self.
__path ):
28 if name
in component._descriptors:
30 setattr( component, name, value )
31 msg.info(
"Set property: %s to value %s of component %s because it matched %s ",
32 name,
str(value), component_path, self.
__path )
33 except Exception
as ex:
34 msg.warning(
"Failed to set property: %s to value %s of component %s because it matched %s, reason: %s",
38 msg.warning(
"No such property: %s in component %s, tried to set it because it matched %s",
39 name, component_path, self.
__path )
43 if ca
is not PropSetterProxy.__scannedCA:
44 PropSetterProxy.__scannedCA = ca
45 PropSetterProxy.__compPaths = {}
46 def __add(path, comp):
47 if comp.getName() ==
"":
49 PropSetterProxy.__compPaths[ path ] = comp
52 for svc
in ca._services:
53 PropSetterProxy.__compPaths[
'SvcMgr/'+svc.getFullJobOptName()] = svc
54 for t
in ca._publicTools:
55 PropSetterProxy.__compPaths[
'ToolSvc/'+t.getFullJobOptName()] = t
56 for t
in ca._conditionsAlgs:
57 PropSetterProxy.__compPaths[t.getFullJobOptName()] = t
59 for t
in ca._privateTools:
60 PropSetterProxy.__compPaths[t.getFullJobOptName()] = t
62 def __nestAlg(startpath, comp):
63 if comp.getName() ==
"":
65 for name, value
in comp._descriptors.items():
66 if isinstance( value.cpp_type, ConfigurableAlgTool )
or isinstance( value.cpp_type, PrivateToolHandle ):
67 __add( startpath+
"/"+name+
"/"+value.getFullJobOptName(), value )
68 __nestAlg( startpath+
"/"+name+
"/"+value.getName(), value )
69 if isinstance( value.cpp_type, PrivateToolHandleArray):
70 for toolIndex,t
in enumerate(value):
71 __add( startpath+
"/"+name+
"/"+t.getFullJobOptName(), t )
72 __nestAlg( startpath+
"/"+name+
"/"+t.getName(), value[toolIndex] )
75 def __nestSeq( startpath, seq ):
78 __nestSeq( startpath+
"/"+c.getName(), c )
80 __add( startpath+
"/"+c.getFullJobOptName(), c )
81 __nestAlg( startpath+
"/"+c.getFullJobOptName(), c )
83 __nestSeq(
"", ca._sequence)