The project root section reads are confined to, for the graph at ``gp``. For a graph in `` /graphify-out`` a ``.graphify_root`` marker may only narrow the root to a folder inside the project, never widen it, so a committed marker cannot open the rest of the disk to reads.
(gp: Path)
| 84 | |
| 85 | |
| 86 | def section_root(gp: Path) -> Path: |
| 87 | """The project root section reads are confined to, for the graph at ``gp``. |
| 88 | |
| 89 | For a graph in ``<project>/graphify-out`` a ``.graphify_root`` marker may |
| 90 | only narrow the root to a folder inside the project, never widen it, so a |
| 91 | committed marker cannot open the rest of the disk to reads. |
| 92 | """ |
| 93 | from graphify.paths import GRAPHIFY_OUT, graph_root_for |
| 94 | |
| 95 | root = graph_root_for(gp) |
| 96 | out = Path(GRAPHIFY_OUT).parts |
| 97 | if out and not Path(GRAPHIFY_OUT).is_absolute() and gp.parent.parts[-len(out):] == out: |
| 98 | project = gp.parent.parents[len(out) - 1] |
| 99 | try: |
| 100 | root.resolve().relative_to(project.resolve()) |
| 101 | except (OSError, RuntimeError, ValueError): |
| 102 | return project |
| 103 | return root |
| 104 | |
| 105 | |
| 106 | def is_section_node(node: dict) -> bool: |