Portable path string used as the registry's identity key. Relative-to-KB posix when the file lives inside the KB (stable across machines/checkouts), absolute posix otherwise. Both paths are fully resolved (symlinks followed) before comparison.
(path: Path, kb_dir: Path)
| 34 | |
| 35 | |
| 36 | def _registry_path(path: Path, kb_dir: Path) -> str: |
| 37 | """Portable path string used as the registry's identity key. |
| 38 | |
| 39 | Relative-to-KB posix when the file lives inside the KB (stable across |
| 40 | machines/checkouts), absolute posix otherwise. Both paths are fully |
| 41 | resolved (symlinks followed) before comparison. |
| 42 | """ |
| 43 | resolved_path = path.resolve() |
| 44 | resolved_kb = kb_dir.resolve() |
| 45 | if resolved_path.is_relative_to(resolved_kb): |
| 46 | return resolved_path.relative_to(resolved_kb).as_posix() |
| 47 | return resolved_path.as_posix() |
| 48 | |
| 49 | |
| 50 | _SAFE_STEM_RE = re.compile(r"[^\w\-]+") |
no outgoing calls