Path rendering — shared by the navigation and bridge layers.
[render_path][] turns a path node into a readable root.a[..].b string
for error messages.
render_path(node)
A readable root.a[..].b rendering of a path position, for error messages.
Source code in capturegraph-lib/capturegraph/procedures/procedure/authoring/paths.py
| def render_path(node: Procedure) -> str:
"""A readable ``root.a[..].b`` rendering of a path position, for error messages."""
from capturegraph.procedures.nodes.destination.access import (
GetRoot,
PathAppend,
PathField,
PathIndex,
PathKey,
PathKeys,
PathValues,
)
if isinstance(node, GetRoot):
return "root"
if isinstance(node, PathField):
return f"{render_path(node.source)}.{node.field}"
if isinstance(node, PathIndex):
return f"{render_path(node.source)}[{node.index}]"
if isinstance(node, PathKey):
return f"{render_path(node.source)}[key]"
if isinstance(node, PathAppend):
return f"{render_path(node.source)}[+]"
if isinstance(node, (PathKeys, PathValues)):
return f"{render_path(node.source)}.{type(node).__name__}"
return str(node)
|