mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-23 10:07:48 -06:00
core.paths holds the default database, platforms, emulators and bios paths, core.cli declares the options built on them (add_repo_inputs) and the --emulator/--system modes verify and generate_pack share. model.targets.target_scope answers --target for a command line, model.profiles.no_profile_for_systems the system with no emulator. tests/sources.declared_options reads the options a script declares through either form.
36 lines
1.2 KiB
Python
36 lines
1.2 KiB
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]
|
|
|
|
|
|
# The inputs a command reads unless told otherwise, relative to the
|
|
# repository root it runs from.
|
|
DB_FILE = "database.json"
|
|
PLATFORMS_DIR = "platforms"
|
|
EMULATORS_DIR = "emulators"
|
|
BIOS_DIR = "bios"
|
|
|
|
|
|
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 ("..", "."))
|
|
|
|
|
|
def declared_destination(entry: dict) -> str:
|
|
"""The destination a declaration names, its name when it names none,
|
|
normalized as sanitize_pack_path does: the key the builder, the manifest
|
|
and verify all file a declaration under."""
|
|
return sanitize_pack_path(entry.get("destination", entry.get("name", "")))
|