Files
libretro/scripts/core/paths.py
T
Abdessamad Derraz 83cfa6fd0f refactor: split common.py into three packages
core: cli (run_cli, input errors, name hints), github (token), paths.
model: sources, database, composition, registry, platforms,
declarations, targets, systems, profiles, cliargs. resolve: content,
ownership, datadirs, archives, localfile, directories, layout,
contentlayout, standalone, grouping, cores.

Definitions move verbatim; common.py and its re-exports are gone and
every importer, patch target and code-in-string names the new home. A
test that stubbed common.load_platform_config stubs each module that
reads the loader by its own name.
2026-11-18 11:09:13 +01:00

21 lines
722 B
Python

"""The repository root, and pack-relative destinations normalized the same way by every reader."""
from __future__ import annotations
from pathlib import Path
# The repository: scripts/core/ is two levels below it.
REPO_ROOT = Path(__file__).resolve().parents[2]
def sanitize_pack_path(raw: str) -> str:
"""Strip traversal components from a relative destination.
The builder and the coverage report key their region grouping on this
value, so they have to derive it the same way: a destination normalized on
one side only would be looked up under a key the other side never emits.
"""
raw = raw.replace("\\", "/")
return "/".join(p for p in raw.split("/") if p and p not in ("..", "."))