MCPcopy
hub / github.com/WEIFENG2333/VideoCaptioner / _get_nested

Function _get_nested

videocaptioner/cli/config.py:164–173  ·  view source on GitHub ↗

Get a value from a nested dict using dotted key notation.

(d: dict, dotted_key: str, default: Any = None)

Source from the content-addressed store, hash-verified

162
163
164def _get_nested(d: dict, dotted_key: str, default: Any = None) -> Any:
165 """Get a value from a nested dict using dotted key notation."""
166 keys = dotted_key.split(".")
167 for key in keys:
168 if not isinstance(d, dict):
169 return default
170 d = d.get(key, default) # type: ignore[assignment]
171 if d is default:
172 return default
173 return d
174
175
176def load_config_file(path: Optional[Path] = None) -> dict:

Callers 5

test_get_nestedMethod · 0.90
getFunction · 0.85
_parse_valueFunction · 0.85

Calls

no outgoing calls

Tested by 3

test_get_nestedMethod · 0.72