48def substituteValue (value, substitutions) :
49 """recursively rewrite container references inside a property value
50
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.
55 """
56 if isinstance (value, str) :
57 new = value
58 for search, replace in substitutions :
59 new = _anchoredReplace (new, search, replace)
60 return new
61
62 if _ELPrivateToolConfig is not None and isinstance (value, _ELPrivateToolConfig) :
63 substituteComponentProperties (value, substitutions)
64 return value
65
66 if _CAConfigurable is not None and isinstance (value, _CAConfigurable) :
67 substituteComponentProperties (value, substitutions)
68 return value
69
70
71
72 if value.__class__.__name__ == 'PrivateToolHandleArray' :
73 for tool in value :
74 substituteComponentProperties (tool, substitutions)
75 return value
76
77
78
79 if value.__class__.__name__ == 'DataHandle' :
80 newPath = substituteValue (value.Path, substitutions)
81 if newPath == value.Path :
82 return value
83 return newPath
84
85
86
87
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)
97 return value
98
99