MCPcopy Create free account
hub / github.com/Graphify-Labs/graphify / graph_root_for

Function graph_root_for

graphify/paths.py:556–580  ·  view source on GitHub ↗

Resolve the selected graph's project without interpreting paths via CWD.

(gp: Path)

Source from the content-addressed store, hash-verified

554
555
556def graph_root_for(gp: Path) -> Path:
557 """Resolve the selected graph's project without interpreting paths via CWD."""
558 try:
559 text = (gp.parent / ".graphify_root").read_text(encoding="utf-8-sig").strip()
560 if text:
561 root = Path(text)
562 if root.is_absolute():
563 try:
564 resolved = root.resolve()
565 except RuntimeError:
566 pass # Path resolution can report a symlink loop this way.
567 else:
568 if resolved.is_dir():
569 return resolved
570 except (OSError, UnicodeError, ValueError):
571 pass
572
573 # CLI-written absolute markers cover shared output. Otherwise strip only
574 # an exact, traversal-free relative output suffix, never a CWD-resolved one.
575 output = Path(GRAPHIFY_OUT)
576 parts = output.parts
577 if (parts and not output.is_absolute() and ".." not in parts
578 and gp.parent.parts[-len(parts):] == parts):
579 return gp.parent.parents[len(parts) - 1]
580 return gp.parent
581
582
583def default_graph_json() -> str:

Callers 2

section_rootFunction · 0.90
_graph_rootFunction · 0.90

Calls 1

resolveMethod · 0.45

Tested by

no test coverage detected