MCPcopy Create free account
hub / github.com/Robbyant/lingbot-depth / recursive_replace

Function recursive_replace

mdm/utils/tools.py:139–149  ·  view source on GitHub ↗
(d: Union[List, Dict, str], mapping: Dict[str, str])

Source from the content-addressed store, hash-verified

137
138
139def recursive_replace(d: Union[List, Dict, str], mapping: Dict[str, str]):
140 if isinstance(d, str):
141 for old, new in mapping.items():
142 d = d.replace(old, new)
143 elif isinstance(d, list):
144 for i, item in enumerate(d):
145 d[i] = recursive_replace(item, mapping)
146 elif isinstance(d, dict):
147 for k, v in d.items():
148 d[k] = recursive_replace(v, mapping)
149 return d
150
151
152class timeit:

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected