INNER CODE UNIT · Python
resolve_path
llm-d/llm-d · scripts/guide.py:269
def resolve_path(guide: Any, path: str) -> tuple[bool, Any, str]:
"""Resolve a dotted/indexed marker path against the parsed YAML.
Returns ``(found, value, error_message)``. A single resolver replaces the
two divergent implementations the split scripts carried — one that raised
``SystemExit`` and one that returned a tuple.
"""
cur = guide
for t in _tokenize_path(path):
if isinstance(t, int):
if not isinstance(cur, list):
return False, None, f"path {path!r}: cannot index into non-list"
if t >= len(cur):
return False, None, f"path {path!r}: list index {t} out of range"
cur = cur[t]
else:
if not isinstance(cur, dict) or t not in cur:
return False, None, f"path {path!r} not found in YAML"