MCPcopy Index your code
hub / github.com/pyinvoke/invoke / excise

Function excise

invoke/config.py:1251–1267  ·  view source on GitHub ↗

Remove key pointed at by ``keypath`` from nested dict ``dict_``, if exists. .. versionadded:: 1.0

(dict_: Dict[str, Any], keypath: Tuple[str, ...])

Source from the content-addressed store, hash-verified

1249
1250
1251def excise(dict_: Dict[str, Any], keypath: Tuple[str, ...]) -> None:
1252 """
1253 Remove key pointed at by ``keypath`` from nested dict ``dict_``, if exists.
1254
1255 .. versionadded:: 1.0
1256 """
1257 data = dict_
1258 keypath_list = list(keypath)
1259 leaf_key = keypath_list.pop()
1260 while keypath_list:
1261 key = keypath_list.pop(0)
1262 if key not in data:
1263 # Not there, nothing to excise
1264 return
1265 data = data[key]
1266 if leaf_key in data:
1267 del data[leaf_key]
1268
1269
1270def obliterate(base: Dict[str, Any], deletions: Dict[str, Any]) -> None:

Callers 1

_modifyMethod · 0.85

Calls 1

popMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…