The file ``source_file`` names, or None when it falls outside ``root``.
(source_file: str, root: Path)
| 71 | |
| 72 | |
| 73 | def _resolve_inside(source_file: str, root: Path) -> "Path | None": |
| 74 | """The file ``source_file`` names, or None when it falls outside ``root``.""" |
| 75 | candidate = Path(source_file) |
| 76 | if not candidate.is_absolute(): |
| 77 | candidate = root / candidate |
| 78 | try: |
| 79 | resolved = candidate.resolve() |
| 80 | resolved.relative_to(root.resolve()) |
| 81 | except (OSError, RuntimeError, ValueError): |
| 82 | return None |
| 83 | return resolved |
| 84 | |
| 85 | |
| 86 | def section_root(gp: Path) -> Path: |