diff --git a/scripts/list_platforms.py b/scripts/list_platforms.py index 4d31a0ca3..5465a35b4 100644 --- a/scripts/list_platforms.py +++ b/scripts/list_platforms.py @@ -14,10 +14,9 @@ import os import sys sys.path.insert(0, os.path.dirname(__file__)) +from core.paths import PLATFORMS_DIR from model.registry import list_registered_platforms -PLATFORMS_DIR = "platforms" - def list_platforms() -> list[str]: """Every registered platform.""" diff --git a/scripts/pipeline.py b/scripts/pipeline.py index f1471ab48..4bffede0c 100644 --- a/scripts/pipeline.py +++ b/scripts/pipeline.py @@ -1298,7 +1298,7 @@ def _verify_steps( # between the packs and the manifests, which would then describe two # revisions of it. Taken after step 2, whose own refresh needs them # exclusive. - hold_data_dirs(held, load_data_dir_registry("platforms")) + hold_data_dirs(held, load_data_dir_registry(PLATFORMS_DIR)) # Step 3: Verify. The paths each pack holds by this report go to a file # step 5 compares with the archives. diff --git a/scripts/provenance_report.py b/scripts/provenance_report.py index e98596c34..47d605e6a 100644 --- a/scripts/provenance_report.py +++ b/scripts/provenance_report.py @@ -25,6 +25,7 @@ import sys sys.path.insert(0, os.path.dirname(__file__)) from core.cli import add_repo_inputs +from core.paths import EMULATORS_DIR from model.dumpcatalog import DEFAULT_PROVENANCE_DIR, load_provenance_snapshots from model.database import load_database from model.profiles import load_emulator_profiles @@ -76,7 +77,7 @@ def main() -> int: ) parser.add_argument("--json", action="store_true", help="Full report as JSON") parser.add_argument( - "--emulators-dir", default="emulators", + "--emulators-dir", default=EMULATORS_DIR, help="profiles whose unheld files a missing dump answers (default: %(default)s)", ) parser.add_argument( diff --git a/scripts/release_notes.py b/scripts/release_notes.py index 594efdbff..249999671 100644 --- a/scripts/release_notes.py +++ b/scripts/release_notes.py @@ -32,6 +32,7 @@ from pathlib import Path from model import releaserecord from core.cli import require_directory +from core.paths import PLATFORMS_DIR from core.artifacts import write_text_atomic from release.notes import ( changelog_url, @@ -49,7 +50,7 @@ def main() -> int: help="release record (default: %(default)s)") parser.add_argument("--whats-new", required=True, type=Path, help="what changed since the previous release, written by hand") - parser.add_argument("--platforms-dir", default="platforms", + parser.add_argument("--platforms-dir", default=PLATFORMS_DIR, help="registry read for each pack's extract folder (default: %(default)s)") parser.add_argument("--thanks", type=Path, help="checked Thanks lines to print instead of the ones gh gives") diff --git a/scripts/release_record.py b/scripts/release_record.py index 421015977..8e39e8d22 100644 --- a/scripts/release_record.py +++ b/scripts/release_record.py @@ -22,6 +22,7 @@ import sys from pathlib import Path from core.artifacts import ArtifactLockBusy, write_text_atomic +from core.paths import PLATFORMS_DIR from core.sizes import size_text from model.releaserecord import RECORD from release.record import ( @@ -41,7 +42,7 @@ def main() -> int: help="manifests the archives are compared with (default: %(default)s)", ) parser.add_argument( - "--platforms-dir", default="platforms", + "--platforms-dir", default=PLATFORMS_DIR, help="registry the pack names are rebuilt from (default: %(default)s)", ) parser.add_argument( diff --git a/scripts/retired_files.py b/scripts/retired_files.py index 27607ba7c..d251955cc 100644 --- a/scripts/retired_files.py +++ b/scripts/retired_files.py @@ -16,7 +16,8 @@ from pathlib import Path sys.path.insert(0, str(Path(__file__).parent)) from core.cli import run_cli from core.artifacts import write_if_changed -from core.paths import REPO_ROOT +from core.paths import DB_FILE, REPO_ROOT +from model.database import load_database from model.retired import FIRST_ADDRESSED, RETIRED_FILE, dump, merge, retired_between @@ -52,7 +53,7 @@ def main() -> int: parser.print_help() return 2 records = backfill() - current = json.loads((REPO_ROOT / "database.json").read_text(encoding="utf-8")) + current = load_database(str(REPO_ROOT / DB_FILE)) records = merge(records, {}, current) write_if_changed(args.output, dump(records)) print(f"{len(records)} files left the collection since {FIRST_ADDRESSED}") diff --git a/scripts/site_insights.py b/scripts/site_insights.py index c08dd7701..63d139089 100644 --- a/scripts/site_insights.py +++ b/scripts/site_insights.py @@ -41,7 +41,7 @@ sys.path.insert(0, os.path.dirname(__file__)) from model.database import load_database from model.profiles import load_emulator_profiles from core.cli import run_cli -from core.paths import REPO_ROOT +from core.paths import DB_FILE, EMULATORS_DIR, REPO_ROOT from sitegen.insights import ( SOURCES, Readings, @@ -73,8 +73,8 @@ def main() -> int: # Search Console data settles two to three days after the fact. end = dt.date.today() - dt.timedelta(days=3) start = end - dt.timedelta(days=args.days - 1) - held, declared = collection_names(load_database(str(REPO_ROOT / "database.json")), - load_emulator_profiles(str(REPO_ROOT / "emulators"))) + held, declared = collection_names(load_database(str(REPO_ROOT / DB_FILE)), + load_emulator_profiles(str(REPO_ROOT / EMULATORS_DIR))) now = dt.datetime.now(dt.timezone.utc) readings = Readings(start, end, now, held, declared) if "gsc" not in skip: diff --git a/scripts/sitesources.py b/scripts/sitesources.py index 54a65bd7b..4cdb7ee0b 100644 --- a/scripts/sitesources.py +++ b/scripts/sitesources.py @@ -9,6 +9,7 @@ import argparse import sys from pathlib import Path +from core.paths import EMULATORS_DIR from sitegen.sources import SOURCE_PATHS, TREE_CACHE, refresh_record @@ -26,7 +27,7 @@ def main() -> int: help="fetch a tree no cache holds into the last --cache-dir", ) parser.add_argument( - "--emulators-dir", default="emulators", + "--emulators-dir", default=EMULATORS_DIR, help="profiles whose citations are checked (default: %(default)s)", ) parser.add_argument( diff --git a/scripts/validate_schemas.py b/scripts/validate_schemas.py index a37488b27..ad8e203bc 100644 --- a/scripts/validate_schemas.py +++ b/scripts/validate_schemas.py @@ -16,7 +16,7 @@ import yaml from model.registry import load_data_dir_registry, load_platform_registry from model.profiles import source_yaml_paths from model.safeparse import yaml_load -from core.paths import PLATFORMS_DIR, REPO_ROOT +from core.paths import DB_FILE, EMULATORS_DIR, PLATFORMS_DIR, REPO_ROOT try: from jsonschema import Draft202012Validator, FormatChecker @@ -475,9 +475,9 @@ def _unknown_data_dir_refs() -> list[str]: every run printed "not cached" while refresh_data_dirs had nothing to refresh. """ - registered = set(load_data_dir_registry(REPO_ROOT / "platforms", required=True)) + registered = set(load_data_dir_registry(REPO_ROOT / PLATFORMS_DIR, required=True)) out: list[str] = [] - for directory in (REPO_ROOT / "emulators", REPO_ROOT / "platforms"): + for directory in (REPO_ROOT / EMULATORS_DIR, REPO_ROOT / PLATFORMS_DIR): for path in source_yaml_paths(directory): if path.name.startswith("_"): continue @@ -505,7 +505,7 @@ def _repository_layout_in_profiles() -> list[str]: `.variants/...`, and the pack then wrote them where no emulator looks. """ out: list[str] = [] - for path in source_yaml_paths(REPO_ROOT / "emulators"): + for path in source_yaml_paths(REPO_ROOT / EMULATORS_DIR): document = _source_mapping(path) for entry in document.get("files") or []: if not isinstance(entry, dict): @@ -604,7 +604,7 @@ def _registry_contract() -> list[str]: registry where no platform carries it would cut a release with no pack at all, and every download link would lead to the command. """ - registry_path = REPO_ROOT / "platforms" / "_registry.yml" + registry_path = REPO_ROOT / PLATFORMS_DIR / "_registry.yml" if not registry_path.is_file(): return [] with registry_path.open(encoding="utf-8") as handle: @@ -681,7 +681,7 @@ def _bios_tree_below(platform: str, folder: str) -> str: from model.platforms import load_platform_config try: - config = load_platform_config(platform, str(REPO_ROOT / "platforms")) + config = load_platform_config(platform, str(REPO_ROOT / PLATFORMS_DIR)) except FileNotFoundError: return "" prefix = f"{folder}/".lower() @@ -701,7 +701,7 @@ def _libretro_systems(platform: str) -> dict: from model.platforms import load_platform_config try: - config = load_platform_config(platform, str(REPO_ROOT / "platforms")) + config = load_platform_config(platform, str(REPO_ROOT / PLATFORMS_DIR)) except FileNotFoundError: return {} return config.get("libretro_systems") or {} @@ -879,7 +879,7 @@ def _romfolder_errors() -> list[str]: """Every scraped setup against its schema, and every source_ref against the sources the file declares: a ref naming no declared repository can never be read back at a pin.""" - directory = REPO_ROOT / "platforms" / "romfolders" + directory = REPO_ROOT / PLATFORMS_DIR / "romfolders" if not directory.is_dir(): return [] validator = _validator("romfolders.schema.json") @@ -938,7 +938,7 @@ def _arcade_pin_errors() -> list[str]: out: list[str] = [] for path in sorted((REPO_ROOT / "games" / "arcade").glob("*.json")): doc = _json_object(path) - profile_path = REPO_ROOT / "emulators" / f"{doc.get('profile')}.yml" + profile_path = REPO_ROOT / EMULATORS_DIR / f"{doc.get('profile')}.yml" label = str(path.relative_to(REPO_ROOT)) if not profile_path.is_file(): out.append(f"{label}: no profile emulators/{profile_path.name}") @@ -1007,11 +1007,11 @@ def main() -> int: errors: list[str] = _format_errors() errors.extend( - _validate_yaml_directory(REPO_ROOT / "emulators", "emulator.schema.json") + _validate_yaml_directory(REPO_ROOT / EMULATORS_DIR, "emulator.schema.json") ) errors.extend( _validate_yaml_directory( - REPO_ROOT / "platforms", "platform.schema.json", skip_private=True + REPO_ROOT / PLATFORMS_DIR, "platform.schema.json", skip_private=True ) ) errors.extend(_unknown_data_dir_refs()) @@ -1025,7 +1025,7 @@ def main() -> int: errors.extend(_arcade_pin_errors()) if not args.source_only: - database_path = REPO_ROOT / "database.json" + database_path = REPO_ROOT / DB_FILE errors.extend( _validate_json_files( [database_path], diff --git a/scripts/validate_site.py b/scripts/validate_site.py index da001b0ff..6852ee58a 100644 --- a/scripts/validate_site.py +++ b/scripts/validate_site.py @@ -14,6 +14,7 @@ import argparse import sys from pathlib import Path +from core.paths import PLATFORMS_DIR from sitegen.validate import validate_site @@ -32,7 +33,7 @@ def main() -> None: help="the path the site is served under (default: %(default)s)", ) parser.add_argument( - "--platforms-dir", default="platforms", type=Path, + "--platforms-dir", default=PLATFORMS_DIR, type=Path, help="registry whose platforms each need a get/ page (default: %(default)s)", ) parser.add_argument(