49 """recursively rewrite container references inside a property value
51 Returns the (possibly new) value; for private-tool values (EventLoop
52 `PrivateToolConfig`, Athena `GaudiConfig2.Configurable`) and for
53 `PrivateToolHandleArray` the tool(s) are mutated in place and the
54 same instance is returned.
56 if isinstance (value, str) :
58 for search, replace
in substitutions :
59 new = _anchoredReplace (new, search, replace)
62 if _ELPrivateToolConfig
is not None and isinstance (value, _ELPrivateToolConfig) :
63 substituteComponentProperties (value, substitutions)
66 if _CAConfigurable
is not None and isinstance (value, _CAConfigurable) :
67 substituteComponentProperties (value, substitutions)
72 if value.__class__.__name__ ==
'PrivateToolHandleArray' :
74 substituteComponentProperties (tool, substitutions)
79 if value.__class__.__name__ ==
'DataHandle' :
80 newPath = substituteValue (value.Path, substitutions)
81 if newPath == value.Path :
88 if isinstance (value, collections.abc.MutableMapping) :
89 return {substituteValue (k, substitutions) : substituteValue (v, substitutions)
90 for k, v
in value.items()}
91 if isinstance (value, collections.abc.MutableSet) :
92 return {substituteValue (v, substitutions)
for v
in value}
93 if isinstance (value, collections.abc.MutableSequence) :
94 return [substituteValue (v, substitutions)
for v
in value]
95 if isinstance (value, tuple) :
96 return tuple (substituteValue (v, substitutions)
for v
in value)
101 """walk a component's user-set properties, substituting container
102 references in every value, and write the result back through
103 `setattr` so the underlying configuration stays in sync."""
104 if hasattr (component,
'_props') :
105 propDict = component._props
106 elif hasattr (component,
'_properties') :
107 propDict = component._properties
110 for propName
in list (propDict.keys()) :
111 old = propDict[propName]
112 new = substituteValue (old, substitutions)
119 setattr (component, propName, new)