From c784aef88335fb81b83821fa772294e2f7e24d62 Mon Sep 17 00:00:00 2001 From: Abdessamad Derraz <3028866+Abdess@users.noreply.github.com> Date: Wed, 18 Nov 2026 10:50:45 +0100 Subject: [PATCH] refactor: move leaf modules into packages core: hashing, artifacts, ziptools, deterministic_zip, romdir, sect233r1, crypto_verify, paths (REPO_ROOT). model: safeparse (needs yaml), dumpcatalog, largefiles, alternatives. resolve: nativemode, validation, launchers, slot, truth, gamedata, and exporter/baseline.py and exporter/candidates.py as resolve/reconcile.py and resolve/categories.py, which truth and gamedata read. Every importer follows. Modules one level deeper read the repository root from core.paths instead of __file__. --- .github/workflows/deploy-site.yml | 56 ++++++++++--------- scripts/archive_build.py | 2 +- scripts/auto_fetch.py | 2 +- scripts/autorun.py | 2 +- scripts/bios_integrity.py | 2 +- scripts/build_installer.py | 2 +- scripts/build_port.py | 2 +- scripts/campaign.py | 2 +- scripts/check_freshness.py | 2 +- scripts/check_release.py | 2 +- scripts/check_release_assets.py | 7 +-- scripts/common.py | 36 ++++++------ scripts/core/__init__.py | 1 + scripts/{ => core}/artifacts.py | 5 +- scripts/{ => core}/crypto_verify.py | 2 +- scripts/{ => core}/deterministic_zip.py | 0 scripts/{ => core}/hashing.py | 0 scripts/core/paths.py | 8 +++ scripts/{ => core}/romdir.py | 0 scripts/{ => core}/sect233r1.py | 0 scripts/{ => core}/ziptools.py | 7 ++- scripts/cross_reference.py | 12 ++-- scripts/diff_truth.py | 2 +- scripts/export_native.py | 8 +-- scripts/exporter/amberelec_exporter.py | 2 +- scripts/exporter/base_exporter.py | 2 +- scripts/exporter/batocera_exporter.py | 2 +- scripts/exporter/bizhawk_exporter.py | 2 +- scripts/exporter/doubled.py | 4 +- scripts/exporter/emudeck_exporter.py | 2 +- scripts/exporter/misterfpga_exporter.py | 2 +- scripts/exporter/recalbox_exporter.py | 2 +- scripts/exporter/retrobat_exporter.py | 2 +- scripts/exporter/retrodeck_exporter.py | 2 +- scripts/exporter/retropie_exporter.py | 2 +- scripts/exporter/rocknix_exporter.py | 2 +- scripts/exporter/romm_exporter.py | 2 +- scripts/exporter/systemdat_exporter.py | 2 +- scripts/fileless_audit.py | 2 +- scripts/game_rules.py | 2 +- scripts/generate_db.py | 2 +- scripts/generate_event_schema.py | 2 +- scripts/generate_games_index.py | 4 +- scripts/generate_installer_doc.py | 2 +- scripts/generate_launcher_index.py | 2 +- scripts/generate_pack.py | 26 +++++---- scripts/generate_readme.py | 2 +- scripts/generate_report_excerpt.py | 2 +- scripts/generate_site.py | 32 +++++------ scripts/generate_truth.py | 2 +- scripts/mame_ref_audit.py | 2 +- scripts/manifestselect.py | 2 +- scripts/model/__init__.py | 1 + scripts/{ => model}/alternatives.py | 0 scripts/{ => model}/dumpcatalog.py | 2 +- scripts/{ => model}/largefiles.py | 7 ++- scripts/{ => model}/safeparse.py | 0 scripts/pack_probe.py | 4 +- scripts/packextras.py | 18 +++--- scripts/packpaths.py | 2 +- scripts/packresolve.py | 8 +-- scripts/packverify.py | 22 ++++---- scripts/profile_sync.py | 2 +- scripts/refresh_data_dirs.py | 2 +- scripts/region_check.py | 2 +- scripts/resolve/__init__.py | 1 + .../candidates.py => resolve/categories.py} | 6 +- scripts/{ => resolve}/gamedata.py | 2 +- scripts/{ => resolve}/launchers.py | 4 +- scripts/{ => resolve}/nativemode.py | 0 .../baseline.py => resolve/reconcile.py} | 6 +- scripts/{ => resolve}/slot.py | 2 +- scripts/{ => resolve}/truth.py | 14 ++--- scripts/{ => resolve}/validation.py | 10 ++-- scripts/restore_large_files.py | 2 +- scripts/romfolders.py | 2 +- scripts/romset_recipes.py | 2 +- scripts/scraper/arcade_parent_importer.py | 2 +- scripts/scraper/batocera_scraper.py | 4 +- scripts/scraper/emuelec_scraper.py | 2 +- scripts/scraper/es_emulators.py | 2 +- scripts/scraper/game_dat_importer.py | 2 +- scripts/scraper/romfolders/__init__.py | 2 +- scripts/scraper/romfolders/__main__.py | 2 +- scripts/scraper/romfolders/es.py | 2 +- scripts/scraper/romset_dat_importer.py | 2 +- .../targets/batocera_targets_scraper.py | 2 +- scripts/sitebootstrap.py | 2 +- scripts/siteguides.py | 2 +- scripts/sitehandheld.py | 2 +- scripts/sitemeasurements.py | 2 +- scripts/siterender.py | 2 +- scripts/sitewanted.py | 4 +- scripts/sitewrite.py | 2 +- scripts/slots.py | 4 +- scripts/split_pack.py | 2 +- scripts/sync_release_assets.py | 7 +-- scripts/upstream.py | 2 +- scripts/validate_pr.py | 6 +- scripts/validate_schemas.py | 6 +- scripts/verify.py | 14 ++--- tests/test_agnostic_substitute.py | 2 +- tests/test_archive_recipes.py | 2 +- tests/test_artifact_lock.py | 2 +- tests/test_atomic_artifacts.py | 2 +- tests/test_audit_regressions.py | 46 +++++++-------- tests/test_batocera_cores.py | 2 +- tests/test_batocera_md5_list.py | 2 +- tests/test_cited_lines.py | 2 +- tests/test_content_checks.py | 4 +- tests/test_content_declarations.py | 2 +- tests/test_core_data_trees.py | 2 +- tests/test_core_size_refusal.py | 2 +- tests/test_crypto_aes.py | 6 +- tests/test_crypto_unique_data.py | 4 +- tests/test_crypto_verify.py | 4 +- tests/test_deterministic_zip.py | 2 +- tests/test_doc_pages.py | 8 +-- tests/test_e2e.py | 38 ++++++------- tests/test_elec_scrapers.py | 2 +- tests/test_entry_categories.py | 11 +--- tests/test_export_counts.py | 12 ++-- tests/test_export_report.py | 12 ++-- tests/test_exporters.py | 25 ++++----- tests/test_fileless_audit.py | 2 +- tests/test_gap_settlement.py | 2 +- tests/test_hashing.py | 2 +- tests/test_install_experience.py | 2 +- tests/test_install_expert.py | 4 +- tests/test_install_selection.py | 2 +- tests/test_large_file_cache.py | 2 +- tests/test_launcher_evidence.py | 2 +- tests/test_launcher_layer.py | 6 +- tests/test_launcher_paths.py | 2 +- tests/test_launcher_placement.py | 6 +- tests/test_libretro_layout.py | 6 +- tests/test_native_mode.py | 2 +- tests/test_profile_checks.py | 10 ++-- tests/test_region.py | 2 +- tests/test_region_held.py | 2 +- tests/test_region_platform_index.py | 2 +- tests/test_romfolders_card.py | 2 +- tests/test_romfolders_es.py | 8 +-- tests/test_romm_hash_rule.py | 4 +- tests/test_save_root.py | 2 +- tests/test_shared_groups.py | 2 +- tests/test_shipped_content.py | 2 +- tests/test_site_exports.py | 2 +- tests/test_site_reference.py | 4 +- tests/test_site_system_sections.py | 2 +- tests/test_site_wanted.py | 2 +- tests/test_slot.py | 8 +-- tests/test_split_pack.py | 2 +- tests/test_standalone_links.py | 2 +- tests/test_tool_messages.py | 2 +- tests/test_truth_data_dir_readers.py | 4 +- tests/test_truth_diff.py | 8 +-- tests/test_truth_layout.py | 12 ++-- tests/test_validate_pr.py | 2 +- tests/test_validated_choice.py | 22 +++----- tests/test_validation_scope.py | 4 +- tests/test_variant_choice.py | 6 +- tests/test_verify_release_asset.py | 2 +- tests/test_zipped_member.py | 2 +- wiki/adding-a-platform.md | 2 +- wiki/release-process.md | 2 +- wiki/verification-modes.md | 10 ++-- 167 files changed, 412 insertions(+), 434 deletions(-) create mode 100644 scripts/core/__init__.py rename scripts/{ => core}/artifacts.py (98%) rename scripts/{ => core}/crypto_verify.py (99%) rename scripts/{ => core}/deterministic_zip.py (100%) rename scripts/{ => core}/hashing.py (100%) create mode 100644 scripts/core/paths.py rename scripts/{ => core}/romdir.py (100%) rename scripts/{ => core}/sect233r1.py (100%) rename scripts/{ => core}/ziptools.py (98%) create mode 100644 scripts/model/__init__.py rename scripts/{ => model}/alternatives.py (100%) rename scripts/{ => model}/dumpcatalog.py (98%) rename scripts/{ => model}/largefiles.py (99%) rename scripts/{ => model}/safeparse.py (100%) create mode 100644 scripts/resolve/__init__.py rename scripts/{exporter/candidates.py => resolve/categories.py} (99%) rename scripts/{ => resolve}/gamedata.py (99%) rename scripts/{ => resolve}/launchers.py (99%) rename scripts/{ => resolve}/nativemode.py (100%) rename scripts/{exporter/baseline.py => resolve/reconcile.py} (99%) rename scripts/{ => resolve}/slot.py (99%) rename scripts/{ => resolve}/truth.py (99%) rename scripts/{ => resolve}/validation.py (99%) diff --git a/.github/workflows/deploy-site.yml b/.github/workflows/deploy-site.yml index 343ac6550..d424e55f2 100644 --- a/.github/workflows/deploy-site.yml +++ b/.github/workflows/deploy-site.yml @@ -11,32 +11,32 @@ on: - "exports/**" # Every script the build runs or imports, and no other # (tests/test_workflow_paths.py). - - "scripts/alternatives.py" - "scripts/archive_build.py" - - "scripts/artifacts.py" - "scripts/auto_fetch.py" - "scripts/build_port.py" - "scripts/common.py" + - "scripts/core/artifacts.py" + - "scripts/core/crypto_verify.py" + - "scripts/core/deterministic_zip.py" + - "scripts/core/hashing.py" + - "scripts/core/paths.py" + - "scripts/core/romdir.py" + - "scripts/core/sect233r1.py" + - "scripts/core/ziptools.py" - "scripts/cross_reference.py" - - "scripts/crypto_verify.py" - - "scripts/derivations.py" - "scripts/dedup.py" - - "scripts/deterministic_zip.py" - - "scripts/dumpcatalog.py" - - "scripts/exporter/baseline.py" - - "scripts/exporter/candidates.py" - - "scripts/gamedata.py" + - "scripts/derivations.py" - "scripts/generate_event_schema.py" - "scripts/generate_pack.py" - "scripts/generate_readme.py" - "scripts/generate_site.py" - - "scripts/hashing.py" - "scripts/indexnow.py" - - "scripts/largefiles.py" - - "scripts/launchers.py" - "scripts/manifestselect.py" - "scripts/measurement_records.py" - - "scripts/nativemode.py" + - "scripts/model/alternatives.py" + - "scripts/model/dumpcatalog.py" + - "scripts/model/largefiles.py" + - "scripts/model/safeparse.py" - "scripts/packextras.py" - "scripts/packpaths.py" - "scripts/packreadme.py" @@ -47,46 +47,48 @@ on: - "scripts/refresh_data_dirs.py" - "scripts/region.py" - "scripts/release_record.py" + - "scripts/resolve/__init__.py" + - "scripts/resolve/categories.py" + - "scripts/resolve/gamedata.py" + - "scripts/resolve/launchers.py" + - "scripts/resolve/nativemode.py" + - "scripts/resolve/reconcile.py" + - "scripts/resolve/slot.py" + - "scripts/resolve/truth.py" + - "scripts/resolve/validation.py" - "scripts/restore_large_files.py" - - "scripts/safeparse.py" + - "scripts/retired_files.py" + - "scripts/romset_recipes.py" - "scripts/scraper/base_scraper.py" - "scripts/scraper/configgen_launchers.py" - "scripts/scraper/shell_launchers.py" - - "scripts/sect233r1.py" - - "scripts/siteagents.py" - "scripts/site_markdown.py" + - "scripts/siteagents.py" - "scripts/sitebootstrap.py" - - "scripts/sitehandheld.py" - - "scripts/sitewanted.py" - "scripts/sitecollection.py" - "scripts/sitediagrams.py" - "scripts/siteentries.py" + - "scripts/siteexports.py" - "scripts/siteguides.py" + - "scripts/sitehandheld.py" - "scripts/siteinputs.py" - "scripts/sitemarkup.py" - "scripts/sitemeasurements.py" - - "scripts/siteexports.py" - "scripts/siterender.py" - - "scripts/retired_files.py" - - "scripts/romset_recipes.py" - - "scripts/romdir.py" - "scripts/sitesources.py" - - "scripts/sitesteps.py" - "scripts/sitestarlight.py" + - "scripts/sitesteps.py" + - "scripts/sitewanted.py" - "scripts/sitewrite.py" - - "scripts/slot.py" - "scripts/slots.py" - "scripts/sourceref.py" - "scripts/split_pack.py" - "scripts/torrentzip.py" - - "scripts/truth.py" - "scripts/upstream.py" - "scripts/validate_pr.py" - "scripts/validate_schemas.py" - "scripts/validate_site.py" - - "scripts/validation.py" - "scripts/verify.py" - - "scripts/ziptools.py" - "schemas/**" - "docs_assets/**" - "install/**" diff --git a/scripts/archive_build.py b/scripts/archive_build.py index bedaf3635..04cb2ec14 100644 --- a/scripts/archive_build.py +++ b/scripts/archive_build.py @@ -105,7 +105,7 @@ def ledger_text(records: dict[str, dict]) -> str: def write_ledger(records: dict[str, dict], path: Path = ARCHIVES_FILE) -> bool: - from artifacts import write_if_changed + from core.artifacts import write_if_changed path.parent.mkdir(parents=True, exist_ok=True) return write_if_changed(str(path), ledger_text(records)) diff --git a/scripts/auto_fetch.py b/scripts/auto_fetch.py index 9f21c26a7..f0b36657f 100644 --- a/scripts/auto_fetch.py +++ b/scripts/auto_fetch.py @@ -86,7 +86,7 @@ def find_missing(config: dict, db: dict) -> list[dict]: checks them inside the zip and holds them, and saw none of the files the cores need that no platform lists. """ - from nativemode import reads_file_contents + from resolve.nativemode import reads_file_contents from verify import Status, verify_platform result = verify_platform(config, db) diff --git a/scripts/autorun.py b/scripts/autorun.py index 9404cb82f..537838224 100644 --- a/scripts/autorun.py +++ b/scripts/autorun.py @@ -548,7 +548,7 @@ def _hardlink_tree(src: Path, dst: Path) -> None: def seed_worktree(repo: Path, worktree: Path) -> list[str]: """Hard-link what git does not carry: a tool deleting a file drops a link.""" - from largefiles import load_registered_paths + from model.largefiles import load_registered_paths seeded = [] for rel in [".cache/large", "data", *load_registered_paths(repo / ".gitignore")]: diff --git a/scripts/bios_integrity.py b/scripts/bios_integrity.py index 1b0a69b17..91fdd4cb8 100644 --- a/scripts/bios_integrity.py +++ b/scripts/bios_integrity.py @@ -43,7 +43,7 @@ from dataclasses import dataclass, field from pathlib import Path sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) -from largefiles import load_registered_paths +from model.largefiles import load_registered_paths MISREAD = "misread" RESTORED = "restored" diff --git a/scripts/build_installer.py b/scripts/build_installer.py index 756f8f5d9..6f893e297 100644 --- a/scripts/build_installer.py +++ b/scripts/build_installer.py @@ -29,7 +29,7 @@ from collections.abc import Iterator from dataclasses import dataclass, field from pathlib import Path -from artifacts import write_text_atomic +from core.artifacts import write_text_atomic ROOT = Path(__file__).resolve().parent.parent PACKAGE = "installer" diff --git a/scripts/build_port.py b/scripts/build_port.py index 144579c3c..3952dc1f6 100644 --- a/scripts/build_port.py +++ b/scripts/build_port.py @@ -38,7 +38,7 @@ import sys import zipfile from pathlib import Path -from artifacts import ArtifactLockBusy, artifact_lock +from core.artifacts import ArtifactLockBusy, artifact_lock REPO_ROOT = Path(__file__).resolve().parent.parent PORT_DIR = "retrobios" diff --git a/scripts/campaign.py b/scripts/campaign.py index c5fcd642b..a6de23888 100644 --- a/scripts/campaign.py +++ b/scripts/campaign.py @@ -1164,7 +1164,7 @@ class Campaign: return result.record def system_entries(self, profile: dict, system: str) -> list[tuple[int, dict]]: - from validation import filter_files_by_mode + from resolve.validation import filter_files_by_mode libretro = filter_files_by_mode(profile.get("files") or [], standalone=False) keep = {id(e) for e in libretro} diff --git a/scripts/check_freshness.py b/scripts/check_freshness.py index 3048a7755..bc2a92678 100644 --- a/scripts/check_freshness.py +++ b/scripts/check_freshness.py @@ -66,7 +66,7 @@ from common import ( yaml_load, ) from exporter import discover_exporters -from exporter.baseline import build_native_model +from resolve.reconcile import build_native_model from scripts.scraper import game_dat_importer from scripts.scraper.redump_dat_scraper import fetch_snapshot from scripts.scraper.targets import discover_target_scrapers diff --git a/scripts/check_release.py b/scripts/check_release.py index 6859f7ee4..15957af05 100644 --- a/scripts/check_release.py +++ b/scripts/check_release.py @@ -33,7 +33,7 @@ from pathlib import Path sys.path.insert(0, os.path.dirname(__file__)) from check_release_assets import digests_of from common import list_release_pack_platforms, require_directory -from largefiles import LARGE_FILES_REPO +from model.largefiles import LARGE_FILES_REPO from release_record import RECORD, load_record SUMS = "SHA256SUMS.txt" diff --git a/scripts/check_release_assets.py b/scripts/check_release_assets.py index e130f4a89..8222f42b4 100644 --- a/scripts/check_release_assets.py +++ b/scripts/check_release_assets.py @@ -26,12 +26,7 @@ from typing import NamedTuple sys.path.insert(0, os.path.dirname(__file__)) from common import composition_tier, load_database -from largefiles import ( - LARGE_FILES_RELEASE, - LARGE_FILES_REPO, - asset_names, - registered_paths, -) +from model.largefiles import LARGE_FILES_RELEASE, LARGE_FILES_REPO, asset_names, registered_paths class AssetFinding(NamedTuple): diff --git a/scripts/common.py b/scripts/common.py index bd9ce05fe..d9e32e2a5 100644 --- a/scripts/common.py +++ b/scripts/common.py @@ -25,21 +25,21 @@ import zipfile from pathlib import Path from typing import TYPE_CHECKING, Any, TextIO, TypedDict -from alternatives import derive_member_requirements +from model.alternatives import derive_member_requirements if TYPE_CHECKING: from typing_extensions import Unpack # Re-exported so the existing call sites keep working while the # modules above become the place to import from. -from safeparse import ( +from model.safeparse import ( parse_untrusted_xml as parse_untrusted_xml, require_yaml as require_yaml, yaml_load as yaml_load, _pick_yaml_loader as _pick_yaml_loader, _YAML_LOADER as _YAML_LOADER, ) -from hashing import ( +from core.hashing import ( compute_hashes as compute_hashes, md5sum as md5sum, md5_composite as md5_composite, @@ -48,7 +48,7 @@ from hashing import ( _ALL_ALGORITHMS as _ALL_ALGORITHMS, _md5_composite_cache as _md5_composite_cache, ) -from ziptools import ( +from core.ziptools import ( check_inside_zip as check_inside_zip, build_zip_contents_index as build_zip_contents_index, MAX_ZIP_MEMBERS as MAX_ZIP_MEMBERS, @@ -61,7 +61,7 @@ from ziptools import ( zip_member_crcs as zip_member_crcs, zip_member_names as zip_member_names, ) -from artifacts import ( +from core.artifacts import ( write_if_changed as write_if_changed, write_text_atomic as write_text_atomic, copy_file_atomic as copy_file_atomic, @@ -77,13 +77,13 @@ from artifacts import ( _TIMESTAMP_PATTERNS as _TIMESTAMP_PATTERNS, _strip_timestamps as _strip_timestamps, ) -from largefiles import ( +from model.largefiles import ( LARGE_FILES_RELEASE as LARGE_FILES_RELEASE, LARGE_FILES_REPO as LARGE_FILES_REPO, LARGE_FILES_CACHE as LARGE_FILES_CACHE, fetch_large_file as fetch_large_file, ) -from dumpcatalog import ( +from model.dumpcatalog import ( DEFAULT_PROVENANCE_DIR as DEFAULT_PROVENANCE_DIR, load_provenance_snapshots as load_provenance_snapshots, build_provenance_index as build_provenance_index, @@ -402,7 +402,7 @@ def declared_content_checks(file_entry: dict) -> set[str]: @functools.lru_cache(maxsize=4096) def _romdir_verdict(path: str, size: int, mtime_ns: int, spec: str) -> bool: - from romdir import romdir_accepts + from core.romdir import romdir_accepts with open(path, "rb") as f: data = f.read() @@ -1518,7 +1518,7 @@ def _required_met(members: list[dict], held: Callable[[dict], bool]) -> tuple[in alternatives, met when one of its members is held: Odin reads the first of three Hikaru boot ROMs it finds in hikaru.zip. """ - from alternatives import groups_of + from model.alternatives import groups_of met = 0 complete = True @@ -3365,7 +3365,7 @@ def standalone_set(config: dict) -> set[str]: for core in entry.get("cores") or [] } if names - {n for n in names if n.startswith(CORE_DIR_PREFIX)}: - from launchers import executed_files, handed_directories + from resolve.launchers import executed_files, handed_directories handed = handed_directories(config) # The record's position travels too: a search list is read in order. @@ -3385,7 +3385,7 @@ def standalone_set(config: dict) -> set[str]: if f.get("name") } # The machines a record offers under its systems, by normalized id. - from launchers import native_systems + from resolve.launchers import native_systems natives = native_systems(config) names |= { @@ -3421,7 +3421,7 @@ def merged_standalone_set(configs: Iterable[dict]) -> set[str]: def _handed(standalone_cores: Iterable[str]) -> list: """The directories a standalone set carries, as launchers built them.""" - from launchers import HandedDirectory + from resolve.launchers import HandedDirectory found = [] for tag in standalone_cores: @@ -3465,7 +3465,7 @@ def entry_launch_systems(entry: dict, index: Mapping[str, set[str]]) -> frozense def _executed(standalone_cores: Iterable[str]) -> list: """The files a standalone set's launchers execute, as launchers read them.""" - from launchers import ExecutedFile + from resolve.launchers import ExecutedFile found = [] for tag in standalone_cores: @@ -3560,7 +3560,7 @@ def standalone_destination( layout = standalone_layout_path(entry, profile) if layout is None or not bindings: return None - from launchers import bound_path + from resolve.launchers import bound_path return bound_path(layout, bindings) @@ -3573,7 +3573,7 @@ def standalone_bindings_for( ``systems`` are those the entry is launched for (entry_launch_systems). """ - from launchers import directory_handles, pool_folders, standalone_bindings + from resolve.launchers import directory_handles, pool_folders, standalone_bindings declared = directory_handles(profile) pools = pool_folders(profile) @@ -3671,7 +3671,7 @@ class _StandaloneLaunches: # The layout folders a search setting stands for (standalone_pools): # bound, the launcher passes the setting and the default is not read. - from launchers import pool_folders as _pool_folders + from resolve.launchers import pool_folders as _pool_folders pool_folders = {v.strip("/") for v in _pool_folders(profile).values()} - {""} return cls( @@ -3931,7 +3931,7 @@ def content_folder_tags(config: dict) -> set[str]: boards = content_folder_boards(config) target = config.get(TARGET_KEY) pairs = {pair for pair, on in boards.items() if not target or on is None or target in on} - from launchers import _roms_place + from resolve.launchers import _roms_place def place(folder: str) -> list: return list(_roms_place(config, folder) or ()) @@ -4081,7 +4081,7 @@ def _libretro_content_layout( # path with stand for these: libretro MAME hands MAME # /mame/bios unless the content's command line names # another (retro_init.cpp Set_Path_Option, execute_game_cmd). - from launchers import pool_folders + from resolve.launchers import pool_folders pools = set(pool_folders({"standalone_pools": view.get("libretro_pools")}).values()) out: list = [] diff --git a/scripts/core/__init__.py b/scripts/core/__init__.py new file mode 100644 index 000000000..38e33a2b9 --- /dev/null +++ b/scripts/core/__init__.py @@ -0,0 +1 @@ +"""Standard-library foundations: hashing, archives, parsing, artifacts, command-line plumbing.""" diff --git a/scripts/artifacts.py b/scripts/core/artifacts.py similarity index 98% rename from scripts/artifacts.py rename to scripts/core/artifacts.py index 1bd492e7d..d032dbe56 100644 --- a/scripts/artifacts.py +++ b/scripts/core/artifacts.py @@ -14,6 +14,7 @@ import os import tempfile import threading import re +from core.paths import REPO_ROOT _TIMESTAMP_PATTERNS = [ @@ -259,7 +260,7 @@ def artifact_lock(directory: str, exclusive: bool = True) -> Iterator[None]: # refused because another module holds it. Nothing else sets it. moved = os.environ.get(REPOSITORY_LOCK_ENV) real = os.path.realpath(directory) - if moved and os.path.isfile(os.path.join(real, "scripts", "artifacts.py")): + if moved and os.path.isfile(os.path.join(real, "scripts", "core", "artifacts.py")): # Keyed by the root's path: a scratch checkout and the process it # spawns name the same root, and find the same lock. lock_dir = os.path.join(moved, real.strip(os.sep).replace(os.sep, "__")) @@ -335,7 +336,7 @@ def hold_repository_outputs(root: str = ".") -> Iterator[None]: yield -_REPO_ROOT = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) +_REPO_ROOT = str(REPO_ROOT) def repository_output_lock(path: str) -> contextlib.AbstractContextManager[None]: diff --git a/scripts/crypto_verify.py b/scripts/core/crypto_verify.py similarity index 99% rename from scripts/crypto_verify.py rename to scripts/core/crypto_verify.py index 9410eb5a0..0ecf18438 100644 --- a/scripts/crypto_verify.py +++ b/scripts/core/crypto_verify.py @@ -375,7 +375,7 @@ def verify_otp( Returns (valid, reason_string). """ - from sect233r1 import _N, _ec_mul, _Gx, _Gy, ecdsa_verify_sha256 + from core.sect233r1 import _N, _ec_mul, _Gx, _Gy, ecdsa_verify_sha256 data = bytearray(Path(filepath).read_bytes()) diff --git a/scripts/deterministic_zip.py b/scripts/core/deterministic_zip.py similarity index 100% rename from scripts/deterministic_zip.py rename to scripts/core/deterministic_zip.py diff --git a/scripts/hashing.py b/scripts/core/hashing.py similarity index 100% rename from scripts/hashing.py rename to scripts/core/hashing.py diff --git a/scripts/core/paths.py b/scripts/core/paths.py new file mode 100644 index 000000000..81c3af536 --- /dev/null +++ b/scripts/core/paths.py @@ -0,0 +1,8 @@ +"""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] diff --git a/scripts/romdir.py b/scripts/core/romdir.py similarity index 100% rename from scripts/romdir.py rename to scripts/core/romdir.py diff --git a/scripts/sect233r1.py b/scripts/core/sect233r1.py similarity index 100% rename from scripts/sect233r1.py rename to scripts/core/sect233r1.py diff --git a/scripts/ziptools.py b/scripts/core/ziptools.py similarity index 98% rename from scripts/ziptools.py rename to scripts/core/ziptools.py index 4567e2ef3..0623553c7 100644 --- a/scripts/ziptools.py +++ b/scripts/core/ziptools.py @@ -16,8 +16,9 @@ import sys import tempfile import zipfile -from artifacts import process_umask, set_plain_mode -from hashing import md5sum +from core.artifacts import process_umask, set_plain_mode +from core.hashing import md5sum +from core.paths import REPO_ROOT def check_inside_zip(container: str, file_name: str, expected_md5: str) -> str: @@ -114,7 +115,7 @@ _zip_contents_cache: tuple[tuple, dict] | None = None # a cached answer is never stale. Every pipeline step that resolves a # zipped_file used to decompress the 54 845 members again, about 23 s each. MEMBER_CACHE = os.path.join( - os.path.dirname(os.path.dirname(os.path.abspath(__file__))), ".cache", "zip_member_md5.json" + REPO_ROOT, ".cache", "zip_member_md5.json" ) diff --git a/scripts/cross_reference.py b/scripts/cross_reference.py index 40e5ba394..486f8d1a9 100644 --- a/scripts/cross_reference.py +++ b/scripts/cross_reference.py @@ -26,7 +26,7 @@ from pathlib import Path from typing import TYPE_CHECKING, TypedDict sys.path.insert(0, os.path.dirname(__file__)) -from alternatives import set_keys, set_requirements, settle_sets +from model.alternatives import set_keys, set_requirements, settle_sets from common import ( OUTER_ROOTS, platform_arg, @@ -56,8 +56,8 @@ from common import ( standalone_set, select_emulator_profiles, ) -from hashing import parse_hash_list -from launchers import ( +from core.hashing import parse_hash_list +from resolve.launchers import ( LauncherLayer, bound_launchers, catalogued_model_files, @@ -69,9 +69,9 @@ from launchers import ( setting_readers, suffixed_stem, ) -from launchers import _directories as launcher_directories -from launchers import _names as launcher_names -from validation import ( +from resolve.launchers import _directories as launcher_directories +from resolve.launchers import _names as launcher_names +from resolve.validation import ( case_folded_slots, declaration_settles, inner_rom_check, diff --git a/scripts/diff_truth.py b/scripts/diff_truth.py index f4971f320..173c2d193 100644 --- a/scripts/diff_truth.py +++ b/scripts/diff_truth.py @@ -26,7 +26,7 @@ from common import ( truth_target_dir, yaml_load, ) -from truth import diff_platform_truth +from resolve.truth import diff_platform_truth yaml = require_yaml() diff --git a/scripts/export_native.py b/scripts/export_native.py index 61e9c236c..200452c88 100644 --- a/scripts/export_native.py +++ b/scripts/export_native.py @@ -32,7 +32,7 @@ from pathlib import Path sys.path.insert(0, str(Path(__file__).resolve().parent)) -from artifacts import file_lock, write_bytes_atomic, write_if_changed, write_text_atomic +from core.artifacts import file_lock, write_bytes_atomic, write_if_changed, write_text_atomic import yaml from common import ( @@ -51,7 +51,7 @@ from common import ( ) from exporter import discover_exporters from exporter.base_exporter import BaseExporter -from exporter.baseline import ( +from resolve.reconcile import ( HASH_FIELDS, NativeFile, Report, @@ -59,9 +59,9 @@ from exporter.baseline import ( _single_size, build_native_model, ) -from exporter.candidates import removal_candidates +from resolve.categories import removal_candidates from exporter.doubled import doubled_destinations -from truth import generate_platform_truth +from resolve.truth import generate_platform_truth DEFAULT_CACHE = ".cache/upstream-native" # The database generate_truth reads by default. diff --git a/scripts/exporter/amberelec_exporter.py b/scripts/exporter/amberelec_exporter.py index 23989cddb..7e2de673e 100644 --- a/scripts/exporter/amberelec_exporter.py +++ b/scripts/exporter/amberelec_exporter.py @@ -9,7 +9,7 @@ every build, and an addition is written the same way. from __future__ import annotations -from .baseline import NativeFile +from resolve.reconcile import NativeFile from .batocera_exporter import Exporter as BatoceraExporter SOURCE_URL = ( diff --git a/scripts/exporter/base_exporter.py b/scripts/exporter/base_exporter.py index 756c922d6..5ed3481ed 100644 --- a/scripts/exporter/base_exporter.py +++ b/scripts/exporter/base_exporter.py @@ -11,7 +11,7 @@ from __future__ import annotations from abc import ABC, abstractmethod from typing import Generic, TypeVar, Union -from .baseline import NativeFile, NativeSystem, Report +from resolve.reconcile import NativeFile, NativeSystem, Report # What a produced file holds: text for every format, bytes besides for one # that also hands back an archive (MiSTer's bios_db.json.zip). diff --git a/scripts/exporter/batocera_exporter.py b/scripts/exporter/batocera_exporter.py index 9122d1b31..565e65dfa 100644 --- a/scripts/exporter/batocera_exporter.py +++ b/scripts/exporter/batocera_exporter.py @@ -12,7 +12,7 @@ import ast import re from .base_exporter import BaseExporter -from .baseline import NativeFile, NativeSystem, Report +from resolve.reconcile import NativeFile, NativeSystem, Report SOURCE_URL = ( "https://raw.githubusercontent.com/batocera-linux/batocera.linux/master" diff --git a/scripts/exporter/bizhawk_exporter.py b/scripts/exporter/bizhawk_exporter.py index 70bdd320d..2b43c40cb 100644 --- a/scripts/exporter/bizhawk_exporter.py +++ b/scripts/exporter/bizhawk_exporter.py @@ -10,7 +10,7 @@ file is served as BizHawk wrote it, checked for its structure. from __future__ import annotations from .base_exporter import BaseExporter -from .baseline import NativeFile, NativeSystem, Report +from resolve.reconcile import NativeFile, NativeSystem, Report SOURCE_URL = ( "https://raw.githubusercontent.com/TASEmulators/BizHawk/master" diff --git a/scripts/exporter/doubled.py b/scripts/exporter/doubled.py index e0e337203..76952b214 100644 --- a/scripts/exporter/doubled.py +++ b/scripts/exporter/doubled.py @@ -22,9 +22,9 @@ from common import ( resolve_platform_cores, standalone_set, ) -from exporter.baseline import HASH_FIELDS, _hash_values +from resolve.reconcile import HASH_FIELDS, _hash_values from slots import _accepted_by_all, _lists_hashes, find_collisions -from validation import opens_by_name, outside_gap_scope +from resolve.validation import opens_by_name, outside_gap_scope def _names(entry: dict) -> set[str]: diff --git a/scripts/exporter/emudeck_exporter.py b/scripts/exporter/emudeck_exporter.py index 47f7a9621..bdfca7f27 100644 --- a/scripts/exporter/emudeck_exporter.py +++ b/scripts/exporter/emudeck_exporter.py @@ -18,7 +18,7 @@ sys.path.insert(0, str(Path(__file__).resolve().parent.parent)) from scraper.emudeck_scraper import FUNCTION_HASH_MAP, _RE_FUNC, _RE_LOCAL_HASHES from .base_exporter import BaseExporter -from .baseline import NativeFile, NativeSystem, Report, _hash_values +from resolve.reconcile import NativeFile, NativeSystem, Report, _hash_values SOURCE_URL = ( "https://raw.githubusercontent.com/dragoonDorise/EmuDeck/main" diff --git a/scripts/exporter/misterfpga_exporter.py b/scripts/exporter/misterfpga_exporter.py index 7fd2ca95f..69898ec8e 100644 --- a/scripts/exporter/misterfpga_exporter.py +++ b/scripts/exporter/misterfpga_exporter.py @@ -14,7 +14,7 @@ from collections import OrderedDict from typing import Union from .base_exporter import BaseExporter -from .baseline import NativeFile, NativeSystem, Report +from resolve.reconcile import NativeFile, NativeSystem, Report SOURCE_URL = ( "https://raw.githubusercontent.com/ajgowans/BiosDB_MiSTer/db/bios_db.json.zip" diff --git a/scripts/exporter/recalbox_exporter.py b/scripts/exporter/recalbox_exporter.py index 210894150..902b244b7 100644 --- a/scripts/exporter/recalbox_exporter.py +++ b/scripts/exporter/recalbox_exporter.py @@ -23,7 +23,7 @@ sys.path.insert(0, str(Path(__file__).resolve().parent.parent)) from common import load_emulator_profiles, parse_untrusted_xml from .base_exporter import BaseExporter -from .baseline import NativeFile, NativeSystem, Report, by_destination, by_name +from resolve.reconcile import NativeFile, NativeSystem, Report, by_destination, by_name SOURCE_URL = ( "https://gitlab.com/recalbox/recalbox/-/raw/master/board/recalbox/fsoverlay" diff --git a/scripts/exporter/retrobat_exporter.py b/scripts/exporter/retrobat_exporter.py index a369d71c2..b625a0a83 100644 --- a/scripts/exporter/retrobat_exporter.py +++ b/scripts/exporter/retrobat_exporter.py @@ -11,7 +11,7 @@ import re from collections import OrderedDict from .base_exporter import BaseExporter -from .baseline import NativeFile, NativeSystem, Report +from resolve.reconcile import NativeFile, NativeSystem, Report SOURCE_URL = ( "https://raw.githubusercontent.com/RetroBat-Official/emulatorlauncher/master" diff --git a/scripts/exporter/retrodeck_exporter.py b/scripts/exporter/retrodeck_exporter.py index 328920cf1..2aeab7dda 100644 --- a/scripts/exporter/retrodeck_exporter.py +++ b/scripts/exporter/retrodeck_exporter.py @@ -13,7 +13,7 @@ import json from collections import OrderedDict from .base_exporter import BaseExporter -from .baseline import NativeFile, NativeSystem, Report +from resolve.reconcile import NativeFile, NativeSystem, Report COMPONENTS_REPO = "RetroDECK/components" COMPONENTS_BRANCH = "main" diff --git a/scripts/exporter/retropie_exporter.py b/scripts/exporter/retropie_exporter.py index bdd8a374b..2e89667ba 100644 --- a/scripts/exporter/retropie_exporter.py +++ b/scripts/exporter/retropie_exporter.py @@ -24,7 +24,7 @@ sys.path.insert(0, str(Path(__file__).resolve().parent.parent)) from common import load_emulator_profiles from .base_exporter import BaseExporter -from .baseline import NativeFile, NativeSystem, Report, search_order +from resolve.reconcile import NativeFile, NativeSystem, Report, search_order SOURCE_URL = ( "https://codeload.github.com/RetroPie/RetroPie-Setup/tar.gz/refs/heads/master" diff --git a/scripts/exporter/rocknix_exporter.py b/scripts/exporter/rocknix_exporter.py index d1a872582..3e531b691 100644 --- a/scripts/exporter/rocknix_exporter.py +++ b/scripts/exporter/rocknix_exporter.py @@ -8,7 +8,7 @@ from __future__ import annotations import re -from .baseline import NativeSystem, Report +from resolve.reconcile import NativeSystem, Report from .batocera_exporter import Exporter as BatoceraExporter SOURCE_URL = ( diff --git a/scripts/exporter/romm_exporter.py b/scripts/exporter/romm_exporter.py index 6fb168485..a22ebcdc4 100644 --- a/scripts/exporter/romm_exporter.py +++ b/scripts/exporter/romm_exporter.py @@ -18,7 +18,7 @@ sys.path.insert(0, str(Path(__file__).resolve().parent.parent)) from scraper.romm_scraper import SLUG_MAP from .base_exporter import BaseExporter -from .baseline import NativeFile, NativeSystem, Report, _hash_values +from resolve.reconcile import NativeFile, NativeSystem, Report, _hash_values SOURCE_URL = ( "https://raw.githubusercontent.com/rommapp/romm/master/backend/models" diff --git a/scripts/exporter/systemdat_exporter.py b/scripts/exporter/systemdat_exporter.py index 6e54f79a7..abc89a013 100644 --- a/scripts/exporter/systemdat_exporter.py +++ b/scripts/exporter/systemdat_exporter.py @@ -16,7 +16,7 @@ sys.path.insert(0, str(Path(__file__).resolve().parent.parent)) from scraper.dat_parser import parse_dat from .base_exporter import BaseExporter -from .baseline import NativeFile, NativeSystem, Report +from resolve.reconcile import NativeFile, NativeSystem, Report SOURCE_URL = ( "https://raw.githubusercontent.com/libretro/libretro-database/master/dat/System.dat" diff --git a/scripts/fileless_audit.py b/scripts/fileless_audit.py index cbb5b1cb1..edb2567a7 100644 --- a/scripts/fileless_audit.py +++ b/scripts/fileless_audit.py @@ -27,7 +27,7 @@ sys.path.insert(0, os.path.dirname(__file__)) import upstream from common import require_directory, suggest_names from profile_sync import collect_citations, ref_role, select_views, split_source_ref -from safeparse import yaml_load +from model.safeparse import yaml_load # Ways a program asks for somewhere to read from. SIGNALS = ( diff --git a/scripts/game_rules.py b/scripts/game_rules.py index 12014f947..1d12e38e7 100644 --- a/scripts/game_rules.py +++ b/scripts/game_rules.py @@ -21,7 +21,7 @@ from pathlib import Path from common import load_emulator_profiles from region import REGIONS, normalize_declared -from safeparse import yaml_load +from model.safeparse import yaml_load REGIONS_FILE = Path("games") / "regions.yml" EXTRAS_FILE = Path("games") / "extras.yml" diff --git a/scripts/generate_db.py b/scripts/generate_db.py index 4c3c460a0..2d1f1d88c 100644 --- a/scripts/generate_db.py +++ b/scripts/generate_db.py @@ -386,7 +386,7 @@ def save_cache(cache_path: str, cache: dict) -> None: def _load_gitignored_large_files() -> set[str]: """The bios/ paths .gitignore registers as release assets.""" - from largefiles import load_registered_paths + from model.largefiles import load_registered_paths return set(load_registered_paths(".gitignore")) diff --git a/scripts/generate_event_schema.py b/scripts/generate_event_schema.py index e12ced373..5c209c12e 100644 --- a/scripts/generate_event_schema.py +++ b/scripts/generate_event_schema.py @@ -13,7 +13,7 @@ import json import sys from pathlib import Path -from artifacts import write_text_atomic +from core.artifacts import write_text_atomic ROOT = Path(__file__).resolve().parent.parent OUTPUT = ROOT / "schemas" / "install-events.schema.json" diff --git a/scripts/generate_games_index.py b/scripts/generate_games_index.py index 959ffce22..10fd227f2 100644 --- a/scripts/generate_games_index.py +++ b/scripts/generate_games_index.py @@ -58,8 +58,8 @@ from romfolders import ( folder_names, load_setups, ) -from artifacts import write_text_atomic -from safeparse import yaml_load +from core.artifacts import write_text_atomic +from model.safeparse import yaml_load import install diff --git a/scripts/generate_installer_doc.py b/scripts/generate_installer_doc.py index 88903a6f0..9e2816d19 100644 --- a/scripts/generate_installer_doc.py +++ b/scripts/generate_installer_doc.py @@ -48,7 +48,7 @@ from pathlib import Path, PurePosixPath from typing import TYPE_CHECKING, Any, Callable import sitehandheld -from artifacts import write_text_atomic +from core.artifacts import write_text_atomic if TYPE_CHECKING: from install import LocalCopy, Progress, _OsRule diff --git a/scripts/generate_launcher_index.py b/scripts/generate_launcher_index.py index f04275b29..bf49c08fd 100644 --- a/scripts/generate_launcher_index.py +++ b/scripts/generate_launcher_index.py @@ -22,7 +22,7 @@ import json import sys from pathlib import Path -from artifacts import write_text_atomic +from core.artifacts import write_text_atomic from build_port import ( BATOCERA_ZIP, MUOS_APP, diff --git a/scripts/generate_pack.py b/scripts/generate_pack.py index ea76c0038..f037f3217 100644 --- a/scripts/generate_pack.py +++ b/scripts/generate_pack.py @@ -21,7 +21,7 @@ if sys.version_info < (3, 9): from collections.abc import Callable, Iterable, Iterator, Mapping -from artifacts import _build_timestamp, set_plain_mode +from core.artifacts import _build_timestamp, set_plain_mode import argparse import contextlib import functools @@ -38,7 +38,7 @@ from dataclasses import dataclass, field from typing import TYPE_CHECKING, TypedDict sys.path.insert(0, os.path.dirname(__file__)) -from alternatives import core_file_spares, settle_sets, slot_set_keys +from model.alternatives import core_file_spares, settle_sets, slot_set_keys from common import resolve_platform_cores as _platform_cores from common import ( ROMS_ROOT, @@ -109,18 +109,20 @@ import packresolve from refresh_data_dirs import cache_lock, hold_data_dirs import region as region_mod from manifestselect import SelectionIndex -import slot as slot_mod +from resolve import slot as slot_mod import slots import split_pack -from gamedata import GAME_DATA, GameDataCut, is_game_data, platform_game_data, without_game_data -from deterministic_zip import _FIXED_DATE_TIME -from largefiles import asset_name, load_registered_paths, published_asset_name -from nativemode import ( - digest_algorithm, - hash_mismatch_excludes_file, - reads_file_contents, +from resolve.gamedata import ( + GAME_DATA, + GameDataCut, + is_game_data, + platform_game_data, + without_game_data, ) -from validation import ( +from core.deterministic_zip import _FIXED_DATE_TIME +from model.largefiles import asset_name, load_registered_paths, published_asset_name +from resolve.nativemode import digest_algorithm, hash_mismatch_excludes_file, reads_file_contents +from resolve.validation import ( baseline_verdict, existence_discrepancy, destination_owners, @@ -6373,7 +6375,7 @@ def _offered_boards( pairs = content_folder_boards(config) if all(on is None for on in pairs.values()): return {} - from launchers import _roms_place + from resolve.launchers import _roms_place by_key: dict[str, set[str]] = {} for name, claimants in upstream_profile_index(profiles).items(): diff --git a/scripts/generate_readme.py b/scripts/generate_readme.py index 67c04a97b..7c3a9f9e1 100644 --- a/scripts/generate_readme.py +++ b/scripts/generate_readme.py @@ -42,7 +42,7 @@ import archive_build import release_record from siteguides import PACKAGE_COMMAND, install_command from validate_pr import LARGE_FILE_ISSUE_URL -from largefiles import LARGE_FILES_CACHE, load_registered_paths +from model.largefiles import LARGE_FILES_CACHE, load_registered_paths import pr_checks from verify import verify_platform diff --git a/scripts/generate_report_excerpt.py b/scripts/generate_report_excerpt.py index 2763eabe3..57de15202 100644 --- a/scripts/generate_report_excerpt.py +++ b/scripts/generate_report_excerpt.py @@ -22,7 +22,7 @@ import subprocess import sys from pathlib import Path -from artifacts import write_text_atomic +from core.artifacts import write_text_atomic ROOT = Path(__file__).resolve().parent.parent PAGE = ROOT / "wiki" / "reading-reports.md" diff --git a/scripts/generate_site.py b/scripts/generate_site.py index 22b2e997f..c00ae2ebe 100644 --- a/scripts/generate_site.py +++ b/scripts/generate_site.py @@ -72,10 +72,10 @@ from common import ( yaml_load, ) from siterender import SECTION_LABELS, WIKI_SRC_DIR -from artifacts import ArtifactLockBusy, artifact_lock -from artifacts import json_text as _json_text +from core.artifacts import ArtifactLockBusy, artifact_lock +from core.artifacts import json_text as _json_text from cross_reference import FileConsumers, entry_target, held_copy -from nativemode import check_label, digest_algorithm, reads_file_contents +from resolve.nativemode import check_label, digest_algorithm, reads_file_contents from generate_readme import ( platform_coverages, @@ -1256,7 +1256,7 @@ def build_emulator_gap_report( if v.get("type") != "alias" and v.get("role") != "test" } from common import merged_standalone_set, platform_declarations - from validation import case_folded_slots + from resolve.validation import case_folded_slots # The command line passes these too: without them a RetroBat file named # 32X_G_BIOS.BIN read as missing for a core opening 32X_G_BIOS.bin. @@ -3724,8 +3724,8 @@ def _served_line(f: dict, declared_sha1: str = "") -> str: def _launcher_refs(config: dict) -> dict[str, list[str]]: """Entry name, casefolded -> each launcher record that opens it, rendered.""" - from launchers import _names as launcher_names - from launchers import bound_launchers + from resolve.launchers import _names as launcher_names + from resolve.launchers import bound_launchers from sitesources import launcher_ref_markdown, list_source # Every scraper reads its launchers in the repository and at the revision @@ -3754,7 +3754,7 @@ def _launcher_unproven_section(config: dict) -> list[str]: A config file is proof only when the code installing it and the code reading it are shown: these records place no file. """ - from launchers import launcher_unproven + from resolve.launchers import launcher_unproven from sitesources import launcher_ref_markdown, list_source rows = launcher_unproven({str(config.get("_key") or ""): config}) @@ -3800,7 +3800,7 @@ def _copy_hash(algorithm: str, value: str | list) -> str: """A declared hash cut to SHORT_HASH characters on a button that copies it whole. A list of accepted values (Recalbox) copies its first. Outside a form a button submits nothing, so it carries no type.""" - from hashing import parse_hash_list + from core.hashing import parse_hash_list values = parse_hash_list(value) if not values: @@ -5170,7 +5170,7 @@ def _data_member_digests( The manifests carry sha1 alone: the MD5 of Dolphin's ApprovedInis.json found nothing although the pack ships it.""" from common import load_data_dir_registry - from hashing import compute_hashes + from core.hashing import compute_hashes if data_registry is None: data_registry = load_data_dir_registry(str(siteinputs.current().platforms)) @@ -5989,7 +5989,7 @@ def _fetch_url(path: str) -> str: large-files release asset when .gitignore keeps it out of git.""" global _RELEASE_ASSET_NAMES if _RELEASE_ASSET_NAMES is None: - from largefiles import ( + from model.largefiles import ( LARGE_FILES_RELEASE, asset_names, load_registered_paths, @@ -8396,7 +8396,7 @@ def comes_with_app(f: dict) -> bool: narrowed by ``mode`` is that build's alone: the other build reads its own entry, or nothing. """ - from validation import installed_with_emulator + from resolve.validation import installed_with_emulator return installed_with_emulator(f) @@ -9020,7 +9020,7 @@ def _more_words(lines: list[str]) -> list[str]: def _short_hash_line(f: dict) -> str: """The entry's strongest declared hash, cut to SHORT_HASH characters, with a copy button for the whole value. "" when it declares none.""" - from hashing import parse_hash_list + from core.hashing import parse_hash_list for field, label in (("sha1", "SHA1"), ("md5", "MD5"), ("sha256", "SHA256"), ("crc32", "CRC32")): values = parse_hash_list(f.get(field) or "") @@ -9961,7 +9961,7 @@ def _hash_spans(value: str | list, copy: bool = False) -> str: that only a profile declares were out of reach of the site search: it indexes text, and a pasted sha1 matched nothing. """ - from hashing import parse_hash_list + from core.hashing import parse_hash_list return ", ".join( markup.hash_value(v, copy) for v in parse_hash_list(value) @@ -11072,7 +11072,7 @@ def _declared_hashes(config: dict, detail: dict) -> dict[str, list[str]]: and named neither: the reader could not look for the dump RetroDECK asks for, nor report the difference. """ - from hashing import parse_hash_list + from core.hashing import parse_hash_list system = (config.get("systems") or {}).get(detail.get("system", "")) or {} for entry in system.get("files") or []: @@ -11394,7 +11394,7 @@ def reading_platforms(emu_name: str, profile: dict, name: str, build of it reads the entry: BlastEm's cdbios.bin is read by the standalone build only, and RetroBat hands that build other names.""" from common import platform_layouts, standalone_set - from validation import filter_files_by_mode, unread_on + from resolve.validation import filter_files_by_mode, unread_on return { platform for platform, config in configs.items() @@ -11507,7 +11507,7 @@ def _corroboration_rows(coverages: dict) -> list[str]: def _divergence_rows(coverages: dict, registry: dict | None, profiles: dict, db: dict) -> list[str]: """Section 1b: platform lists vs emulator source, one row a platform.""" - from truth import diff_platform_truth, generate_platform_truth + from resolve.truth import diff_platform_truth, generate_platform_truth div_rows = [] for pname, cov in _by_platform_name(coverages): diff --git a/scripts/generate_truth.py b/scripts/generate_truth.py index 9ae89d442..1245e56c2 100644 --- a/scripts/generate_truth.py +++ b/scripts/generate_truth.py @@ -28,7 +28,7 @@ from common import ( write_text_atomic, yaml_load, ) -from truth import generate_platform_truth +from resolve.truth import generate_platform_truth yaml = require_yaml() diff --git a/scripts/mame_ref_audit.py b/scripts/mame_ref_audit.py index 387e42fd3..8c718f51a 100644 --- a/scripts/mame_ref_audit.py +++ b/scripts/mame_ref_audit.py @@ -28,7 +28,7 @@ sys.path.insert(0, os.path.dirname(__file__)) import upstream from common import require_directory -from safeparse import yaml_load +from model.safeparse import yaml_load from scraper.mame_parser import _MACHINE_MACROS, strip_comments # An optional role word names the repository the lines are in. diff --git a/scripts/manifestselect.py b/scripts/manifestselect.py index 9a6434d00..e489f2953 100644 --- a/scripts/manifestselect.py +++ b/scripts/manifestselect.py @@ -18,7 +18,7 @@ from __future__ import annotations from dataclasses import dataclass import region as region_mod -import slot as slot_mod +from resolve import slot as slot_mod from common import _norm_system_id, sanitize_pack_path from packextras import ( _kept, diff --git a/scripts/model/__init__.py b/scripts/model/__init__.py new file mode 100644 index 000000000..edcad6f7f --- /dev/null +++ b/scripts/model/__init__.py @@ -0,0 +1 @@ +"""Data loading: database, platforms and registry, profiles, targets, systems, catalogues.""" diff --git a/scripts/alternatives.py b/scripts/model/alternatives.py similarity index 100% rename from scripts/alternatives.py rename to scripts/model/alternatives.py diff --git a/scripts/dumpcatalog.py b/scripts/model/dumpcatalog.py similarity index 98% rename from scripts/dumpcatalog.py rename to scripts/model/dumpcatalog.py index 4c8ef5dc7..1be2c1d0d 100644 --- a/scripts/dumpcatalog.py +++ b/scripts/model/dumpcatalog.py @@ -8,7 +8,7 @@ from __future__ import annotations import json from pathlib import Path -from artifacts import write_if_changed +from core.artifacts import write_if_changed DEFAULT_PROVENANCE_DIR = "provenance" diff --git a/scripts/largefiles.py b/scripts/model/largefiles.py similarity index 99% rename from scripts/largefiles.py rename to scripts/model/largefiles.py index 94adb9f0b..6bc3c6784 100644 --- a/scripts/largefiles.py +++ b/scripts/model/largefiles.py @@ -20,8 +20,9 @@ from collections import Counter from collections.abc import Iterable from pathlib import Path -from artifacts import set_plain_mode -from hashing import compute_hashes +from core.artifacts import set_plain_mode +from core.hashing import compute_hashes +from core.paths import REPO_ROOT LARGE_FILES_RELEASE = "large-files" @@ -34,7 +35,7 @@ LARGE_FILES_CACHE = ".cache/large" # last: callers read the extension (an archive is packed as one). VERIFIED_STORE = ".by-sha1" ORPHAN_GRACE = 24 * 3600 -GITIGNORE = Path(__file__).resolve().parent.parent / ".gitignore" +GITIGNORE = REPO_ROOT / ".gitignore" _UNSAFE_ASSET_CHARS = re.compile(r"[^A-Za-z0-9._-]+") diff --git a/scripts/safeparse.py b/scripts/model/safeparse.py similarity index 100% rename from scripts/safeparse.py rename to scripts/model/safeparse.py diff --git a/scripts/pack_probe.py b/scripts/pack_probe.py index 7cdff2b50..2594e8aac 100644 --- a/scripts/pack_probe.py +++ b/scripts/pack_probe.py @@ -73,8 +73,8 @@ from common import ( run_cli, runs_standalone, ) -from validation import filter_files_by_mode -from ziptools import safe_extract_zip +from resolve.validation import filter_files_by_mode +from core.ziptools import safe_extract_zip ROOT = Path(__file__).resolve().parent.parent MAIN = autorun.main_checkout() diff --git a/scripts/packextras.py b/scripts/packextras.py index 464150244..d797b4526 100644 --- a/scripts/packextras.py +++ b/scripts/packextras.py @@ -11,7 +11,7 @@ from dataclasses import dataclass, field from typing import TYPE_CHECKING, TypedDict from common import PROFILE_IDENTITY_FIELDS, _norm_system_id, entry_system_ids -from alternatives import core_file_spares, required_only_spares, set_fields +from model.alternatives import core_file_spares, required_only_spares, set_fields from common import archive_members, contents_members, holds_required_members from common import declared_root, expand_platform_declared_names, platform_declarations from common import load_emulator_profiles @@ -22,7 +22,7 @@ from common import core_system_dirs, platform_layouts, system_dir_path from common import standalone_set as platform_standalone_set from common import OUTER_ROOTS, outer_layout, sanitize_pack_path from common import declares_shape, shape_fits, size_fits -from validation import deliverable, read_from_save_dir, read_from_system_dir +from resolve.validation import deliverable, read_from_save_dir, read_from_system_dir from packpaths import libretro_systems, save_destination, save_layout from region import FILE_GROUP @@ -260,7 +260,7 @@ def native_slug_systems(config: dict) -> set[str]: def _file_sha1(path: str) -> str | None: """sha1 of a copy the database does not index, a data tree's file.""" - from hashing import compute_hashes + from core.hashing import compute_hashes try: return compute_hashes(path, frozenset({"sha1"}))["sha1"] @@ -314,7 +314,7 @@ class ExtraResolver: def alternatives(self, fe: dict) -> list[dict]: """The versions the extra's own profile accepts at its slot, as validation.extra_alternatives finds them.""" - from validation import slot_index + from resolve.validation import slot_index key = fe.get("source_profile") or "" index = self._slots.get(key) @@ -327,7 +327,7 @@ class ExtraResolver: def resolve(self, fe: dict, dest: str) -> tuple[str | None, str, str]: """(local copy or None, resolver status, the core's disagreement).""" from packresolve import pending_release_asset, resolve_file, run_is_offline - from validation import core_size_refusal, validated_choice + from resolve.validation import core_size_refusal, validated_choice local_path, status = resolve_file( fe, self.db, self.bios_dir, self.zip_contents, @@ -2121,7 +2121,7 @@ def _ships( AmberELEC's bluemsx config.ini read as missing while the pack held it. """ from packresolve import resolve_declaration - from validation import baseline_verdict + from resolve.validation import baseline_verdict path, status = resolve_declaration( file_entry, db, "bios", zip_contents, data_registry, override, offline=True, @@ -2320,7 +2320,7 @@ def emulator_region_drops( """ import region as region_mod from packpaths import _resolve_destination - from validation import _build_validation_index, filter_files_by_mode + from resolve.validation import _build_validation_index, filter_files_by_mode region_index = region_mod.build_region_index(dict(selected)) region_groups: dict[str, list[tuple[str, str]]] = {} @@ -2365,7 +2365,7 @@ def emulator_required_spares( those the pack still carries after the region filter. An archive unit is a member like a loose file: Kronos reads kronos/stvbios.zip, else stvbios.zip. The pack and verify --emulator both read this.""" - from alternatives import groups_of, rank_in, required_groups + from model.alternatives import groups_of, rank_in, required_groups from common import archive_entry from packpaths import _archive_destination, _resolve_destination @@ -2413,7 +2413,7 @@ def _emulator_ships( held it. """ from packresolve import resolve_file - from validation import validated_choice, with_archive_members + from resolve.validation import validated_choice, with_archive_members local, status = resolve_file( {**with_archive_members(file_entry, profile.get("files", [])), diff --git a/scripts/packpaths.py b/scripts/packpaths.py index 045417a45..2514d16fc 100644 --- a/scripts/packpaths.py +++ b/scripts/packpaths.py @@ -10,7 +10,7 @@ from collections.abc import Iterable from dataclasses import dataclass from common import sanitize_pack_path -from validation import read_from_save_dir +from resolve.validation import read_from_save_dir @dataclass(frozen=True) diff --git a/scripts/packresolve.py b/scripts/packresolve.py index 8f64b55b9..2307a36e4 100644 --- a/scripts/packresolve.py +++ b/scripts/packresolve.py @@ -13,15 +13,15 @@ import urllib.error import urllib.request from pathlib import Path -from largefiles import fetch_large_file -from hashing import cut_md5_owner +from model.largefiles import fetch_large_file +from core.hashing import cut_md5_owner from common import ( declared_hash_verdict, resolution_is_hash_exact, resolve_local_file, sanitize_pack_path, ) -from validation import inner_rom_check +from resolve.validation import inner_rom_check # CLI-wide network policy. Public helpers can override it explicitly, while # every CLI mode inherits --offline (including large-file release fallback). _OFFLINE = False @@ -173,7 +173,7 @@ def pending_release_asset( asset the cache lacks was reported missing while an online build packed it. ``registered`` is the .gitignore registry (load_registered_paths). """ - from largefiles import asset_candidates, asset_names, load_registered_paths + from model.largefiles import asset_candidates, asset_names, load_registered_paths name = file_entry.get("name", "") if not name or name.endswith("/") or file_entry.get("type") == "directory": diff --git a/scripts/packverify.py b/scripts/packverify.py index 3f7e191cb..39b5ebfcf 100644 --- a/scripts/packverify.py +++ b/scripts/packverify.py @@ -11,31 +11,31 @@ from dataclasses import dataclass, field from typing import TYPE_CHECKING, TypedDict from auto_fetch import DEFAULT_BIOS_DIR -from artifacts import _build_timestamp +from core.artifacts import _build_timestamp from packpaths import MEDIA_MARKER, _has_path_conflict -from ziptools import build_zip_contents_index -from ziptools import check_inside_zip -from nativemode import digest_algorithm -from validation import baseline_verdict, digest_verdict -from nativemode import hash_mismatch_excludes_file +from core.ziptools import build_zip_contents_index +from core.ziptools import check_inside_zip +from resolve.nativemode import digest_algorithm +from resolve.validation import baseline_verdict, digest_verdict +from resolve.nativemode import hash_mismatch_excludes_file import functools import hashlib import zlib import sys from common import filter_systems_by_target -from hashing import md5_composite_of, parse_md5_list +from core.hashing import md5_composite_of, parse_md5_list import io from common import load_emulator_profiles from common import load_platform_config import os from packextras import platform_region_groups from packpaths import _flat -from nativemode import reads_file_contents +from resolve.nativemode import reads_file_contents import region as region_mod import slots from packresolve import resolve_declaration, resolve_file -from exporter.candidates import BIOS, EntryCategories -from gamedata import without_game_data +from resolve.categories import BIOS, EntryCategories +from resolve.gamedata import without_game_data from common import resolve_platform_cores from common import sanitize_pack_path import zipfile @@ -616,7 +616,7 @@ def _builder_extras( there: taken by the refused file, that core file was never compared. """ from packextras import ExtraResolver, hidden_extras - from validation import _build_validation_index, destination_owners + from resolve.validation import _build_validation_index, destination_owners config, emu_profiles = expect.config, expect.emu_profiles data_registry = expect.opts.data_registry diff --git a/scripts/profile_sync.py b/scripts/profile_sync.py index 30d7114fb..f268b8824 100644 --- a/scripts/profile_sync.py +++ b/scripts/profile_sync.py @@ -44,7 +44,7 @@ from common import ( suggest_names, system_index, ) -from hashing import parse_hash_list +from core.hashing import parse_hash_list from sourceref import ( # re-exported for callers and tests _ANNOTATION_RE as _ANNOTATION_RE, _BARE_RANGE_RE as _BARE_RANGE_RE, diff --git a/scripts/refresh_data_dirs.py b/scripts/refresh_data_dirs.py index f0fd8ed74..c5bac6971 100644 --- a/scripts/refresh_data_dirs.py +++ b/scripts/refresh_data_dirs.py @@ -26,7 +26,7 @@ import urllib.request import zipfile from collections.abc import Callable, Iterator from pathlib import Path -from artifacts import file_lock as _file_lock, set_plain_mode +from core.artifacts import file_lock as _file_lock, set_plain_mode from common import InputMissing, github_token, platform_arg, require_platform, suggest_names, yaml_load try: diff --git a/scripts/region_check.py b/scripts/region_check.py index a9ee7c49c..51f8be5b3 100644 --- a/scripts/region_check.py +++ b/scripts/region_check.py @@ -276,7 +276,7 @@ def nightly_core(core: str) -> tuple[Path, str]: def pack_files(emulator: str, region: str, work: Path) -> dict[str, Path]: """The files generate_pack puts in the emulator's pack for one region, extracted, by their path in the pack.""" - from ziptools import safe_extract_zip + from core.ziptools import safe_extract_zip out_dir = work / "pack" subprocess.run([sys.executable, str(ROOT / "scripts" / "generate_pack.py"), "--emulator", emulator, diff --git a/scripts/resolve/__init__.py b/scripts/resolve/__init__.py new file mode 100644 index 000000000..051c534d0 --- /dev/null +++ b/scripts/resolve/__init__.py @@ -0,0 +1 @@ +"""From declarations to files: content checks, resolution, layouts, cores, truth.""" diff --git a/scripts/exporter/candidates.py b/scripts/resolve/categories.py similarity index 99% rename from scripts/exporter/candidates.py rename to scripts/resolve/categories.py index 6c2faaa89..fd0b72c2f 100644 --- a/scripts/exporter/candidates.py +++ b/scripts/resolve/categories.py @@ -11,16 +11,14 @@ the platform names that no profile describes leaves the verdict open. from __future__ import annotations -import sys from collections.abc import Iterable from dataclasses import dataclass, field from pathlib import Path -sys.path.insert(0, str(Path(__file__).resolve().parent.parent)) from common import _norm_system_id, resolve_platform_cores, unresolved_platform_cores -from exporter.baseline import HASH_FIELDS, NativeSystem, _hash_values -from launchers import _names as launcher_names +from resolve.reconcile import HASH_FIELDS, NativeSystem, _hash_values +from resolve.launchers import _names as launcher_names def _tails(path: str) -> list[str]: diff --git a/scripts/gamedata.py b/scripts/resolve/gamedata.py similarity index 99% rename from scripts/gamedata.py rename to scripts/resolve/gamedata.py index 9a76c16df..837f1d88e 100644 --- a/scripts/gamedata.py +++ b/scripts/resolve/gamedata.py @@ -16,7 +16,7 @@ from __future__ import annotations from dataclasses import dataclass from common import resolve_platform_cores -from exporter.candidates import GAME_DATA, EntryCategories +from resolve.categories import GAME_DATA, EntryCategories @dataclass(frozen=True) diff --git a/scripts/launchers.py b/scripts/resolve/launchers.py similarity index 99% rename from scripts/launchers.py rename to scripts/resolve/launchers.py index 3793db813..16276b428 100644 --- a/scripts/launchers.py +++ b/scripts/resolve/launchers.py @@ -21,6 +21,7 @@ from collections.abc import Callable, Iterable, Mapping from dataclasses import dataclass from common import declared_root, name_match_size_ok, resolve_local_file, sanitize_pack_path +from core.paths import REPO_ROOT # The kinds whose names say which file the launcher opens. A link of a named # file is one too: ROCKNIX links /storage/roms/bios/nds_bios_arm9.bin into @@ -507,12 +508,11 @@ def _profiles_or_repo(profiles: Mapping[str, dict] | None) -> Mapping[str, dict] if profiles is not None: return profiles if _DEFAULT_PROFILES is None: - from pathlib import Path from common import load_emulator_profiles _DEFAULT_PROFILES = load_emulator_profiles( - str(Path(__file__).resolve().parent.parent / "emulators") + str(REPO_ROOT / "emulators") ) return _DEFAULT_PROFILES diff --git a/scripts/nativemode.py b/scripts/resolve/nativemode.py similarity index 100% rename from scripts/nativemode.py rename to scripts/resolve/nativemode.py diff --git a/scripts/exporter/baseline.py b/scripts/resolve/reconcile.py similarity index 99% rename from scripts/exporter/baseline.py rename to scripts/resolve/reconcile.py index 19f12096c..b5a401cac 100644 --- a/scripts/exporter/baseline.py +++ b/scripts/resolve/reconcile.py @@ -13,14 +13,12 @@ grouping is rebuilt from the per-file native_system the scrapers record. from __future__ import annotations -import sys from collections.abc import Callable from dataclasses import dataclass, field -from pathlib import Path -sys.path.insert(0, str(Path(__file__).resolve().parent.parent)) from common import _norm_system_id +from core.paths import REPO_ROOT HASH_FIELDS = ("sha1", "md5", "sha256", "crc32") @@ -778,7 +776,7 @@ def _attach_runners(systems: dict[str, NativeSystem], scraped: dict | None) -> N declared = scraped.get("cores") libretro = {str(c) for c in declared} if isinstance(declared, list) else set() standalone = {str(c) for c in scraped.get("standalone_cores") or []} - profiles = load_emulator_profiles(str(Path(__file__).resolve().parents[2] / "emulators")) + profiles = load_emulator_profiles(str(REPO_ROOT / "emulators")) for system in systems.values(): for fe in system.files: if fe.platform is not None or not fe.truth: diff --git a/scripts/slot.py b/scripts/resolve/slot.py similarity index 99% rename from scripts/slot.py rename to scripts/resolve/slot.py index 3a25736da..1fafb3761 100644 --- a/scripts/slot.py +++ b/scripts/resolve/slot.py @@ -29,7 +29,7 @@ rank: the second core reads it by its own rule, which no rank expresses. from __future__ import annotations -from alternatives import set_keys +from model.alternatives import set_keys BIOS_CATEGORY = "bios" diff --git a/scripts/truth.py b/scripts/resolve/truth.py similarity index 99% rename from scripts/truth.py rename to scripts/resolve/truth.py index de1bf8e80..fba53300c 100644 --- a/scripts/truth.py +++ b/scripts/resolve/truth.py @@ -10,7 +10,6 @@ import copy import os import sys from dataclasses import dataclass -from pathlib import Path from common import ( OUTER_ROOTS, @@ -20,15 +19,16 @@ from common import ( resolve_platform_cores, standalone_set as platform_standalone_set, ) -from alternatives import groups_of -from hashing import compute_hashes -from validation import ( +from model.alternatives import groups_of +from core.hashing import compute_hashes +from resolve.validation import ( filter_files_by_mode, installed_with_emulator, opens_by_name, read_from_system_dir, unread_on, ) +from core.paths import REPO_ROOT _CONFLICTS_SHOWN: set[tuple[str, ...]] = set() @@ -571,7 +571,7 @@ def _declaration_verdict(entry: dict, declaration: dict, db: dict | None) -> str return "undecided" -_REPO_PLATFORMS = Path(__file__).resolve().parent.parent / "platforms" +_REPO_PLATFORMS = REPO_ROOT / "platforms" def _fold_data_directory_readers( @@ -942,7 +942,7 @@ def _hash_mismatch(t_entry: dict, s_entry: dict) -> dict | None: contradicts nothing (checked_hashes), and a platform md5 that is a composite of a zip's members is no container md5 (comparable). """ - from exporter.baseline import contradicted_hashes + from resolve.reconcile import contradicted_hashes fields = contradicted_hashes(t_entry, s_entry) if not fields: @@ -965,7 +965,7 @@ def _diff_system(truth_sys: dict, scraped_sys: dict) -> dict: correct while the export corrected hashes the diff never named. An entry never answers for two. """ - from exporter.baseline import _is_placeholder, is_label, pair_entries, platform_declares + from resolve.reconcile import _is_placeholder, is_label, pair_entries, platform_declares truth_files = [ fe for fe in truth_sys.get("files", []) diff --git a/scripts/validation.py b/scripts/resolve/validation.py similarity index 99% rename from scripts/validation.py rename to scripts/resolve/validation.py index c07aebf6b..a11f14a99 100644 --- a/scripts/validation.py +++ b/scripts/resolve/validation.py @@ -25,9 +25,9 @@ from common import ( sanitize_pack_path, shape_fits, ) -from hashing import md5_composite, parse_hash_list, parse_md5_list -from nativemode import SIZE_AND_ANY_HASH, digest_algorithm, hash_mismatch_excludes_file -from ziptools import check_inside_zip +from core.hashing import md5_composite, parse_hash_list, parse_md5_list +from resolve.nativemode import SIZE_AND_ANY_HASH, digest_algorithm, hash_mismatch_excludes_file +from core.ziptools import check_inside_zip if TYPE_CHECKING: from typing_extensions import Unpack @@ -169,7 +169,7 @@ def _rule_failure( if check not in skip and not content_fits({"validation": [check], check: spec}, local_path): return _CONTENT_REASONS[check] if rule["crypto"] - skip: - from crypto_verify import check_crypto_validation + from core.crypto_verify import check_crypto_validation return check_crypto_validation(local_path, filename, bios_dir) return None @@ -539,7 +539,7 @@ def check_file_validation( # Signature/crypto checks (3DS RSA, AES) if entry["crypto_only"]: - from crypto_verify import check_crypto_validation + from core.crypto_verify import check_crypto_validation crypto_reason = check_crypto_validation(local_path, filename, bios_dir) if crypto_reason: diff --git a/scripts/restore_large_files.py b/scripts/restore_large_files.py index a902d38a7..e08da8a2e 100644 --- a/scripts/restore_large_files.py +++ b/scripts/restore_large_files.py @@ -24,7 +24,7 @@ import sys import tempfile sys.path.insert(0, os.path.dirname(__file__)) -from artifacts import set_plain_mode +from core.artifacts import set_plain_mode from common import copy_file_atomic, load_database diff --git a/scripts/romfolders.py b/scripts/romfolders.py index e096eb9fc..a80da0507 100644 --- a/scripts/romfolders.py +++ b/scripts/romfolders.py @@ -25,7 +25,7 @@ from common import ( preferred_profile, upstream_profile_index, ) -from safeparse import yaml_load +from model.safeparse import yaml_load ROMFOLDERS_DIR = Path("platforms") / "romfolders" SOURCES_DIR = ROMFOLDERS_DIR / "_sources" diff --git a/scripts/romset_recipes.py b/scripts/romset_recipes.py index c2adaf235..079b0d424 100644 --- a/scripts/romset_recipes.py +++ b/scripts/romset_recipes.py @@ -210,7 +210,7 @@ class AtomPool: """Write the digest cache back, when this run learned anything.""" if self._digest_cache is None or not self._digests_changed: return - from artifacts import write_text_atomic + from core.artifacts import write_text_atomic self._digest_cache.parent.mkdir(parents=True, exist_ok=True) write_text_atomic( diff --git a/scripts/scraper/arcade_parent_importer.py b/scripts/scraper/arcade_parent_importer.py index da9a231c3..4abd4c1b9 100644 --- a/scripts/scraper/arcade_parent_importer.py +++ b/scripts/scraper/arcade_parent_importer.py @@ -50,7 +50,7 @@ from dataclasses import dataclass, field from pathlib import Path from typing import IO -from ..artifacts import write_if_changed +from core.artifacts import write_if_changed from ..common import load_emulator_profiles, run_cli from .romset_dat_importer import ( LISTXML_CHUNK, diff --git a/scripts/scraper/batocera_scraper.py b/scripts/scraper/batocera_scraper.py index 0b6e7d12f..7072295c6 100644 --- a/scripts/scraper/batocera_scraper.py +++ b/scripts/scraper/batocera_scraper.py @@ -19,8 +19,8 @@ from pathlib import Path from common import load_target_config, yaml_load -from hashing import cut_md5_owner -from safeparse import yaml_load_upstream +from core.hashing import cut_md5_owner +from model.safeparse import yaml_load_upstream from .base_scraper import ( BaseScraper, diff --git a/scripts/scraper/emuelec_scraper.py b/scripts/scraper/emuelec_scraper.py index 1d544f4ad..d678a0251 100644 --- a/scripts/scraper/emuelec_scraper.py +++ b/scripts/scraper/emuelec_scraper.py @@ -31,7 +31,7 @@ import shlex import urllib.error import urllib.request -from safeparse import yaml_load_upstream +from model.safeparse import yaml_load_upstream from .base_scraper import BaseScraper, BiosRequirement, fetch_github_latest_version from .batocera_scraper import ( diff --git a/scripts/scraper/es_emulators.py b/scripts/scraper/es_emulators.py index 12da77bde..61efaea98 100644 --- a/scripts/scraper/es_emulators.py +++ b/scripts/scraper/es_emulators.py @@ -14,7 +14,7 @@ from __future__ import annotations import json from collections.abc import Iterable, Mapping -from safeparse import parse_untrusted_xml +from model.safeparse import parse_untrusted_xml # system -> [(emulator, [core, ...]), ...], both in the list's order. SystemEmulators = dict[str, list[tuple[str, list[str]]]] diff --git a/scripts/scraper/game_dat_importer.py b/scripts/scraper/game_dat_importer.py index c4bb05605..d59f64230 100644 --- a/scripts/scraper/game_dat_importer.py +++ b/scripts/scraper/game_dat_importer.py @@ -39,7 +39,7 @@ from pathlib import Path if (_SCRIPTS_DIR := str(Path(__file__).resolve().parents[1])) not in sys.path: sys.path.insert(0, _SCRIPTS_DIR) -from artifacts import copy_stream_atomic, write_if_changed, write_text_atomic +from core.artifacts import copy_stream_atomic, write_if_changed, write_text_atomic from common import parse_untrusted_xml from region import REGIONS, WORLD from region_audit import NOINTRO diff --git a/scripts/scraper/romfolders/__init__.py b/scripts/scraper/romfolders/__init__.py index b5b4923f5..695183c48 100644 --- a/scripts/scraper/romfolders/__init__.py +++ b/scripts/scraper/romfolders/__init__.py @@ -24,7 +24,7 @@ if (_SCRIPTS_DIR := str(Path(__file__).resolve().parents[2])) not in sys.path: sys.path.insert(0, _SCRIPTS_DIR) import upstream -from safeparse import yaml_load +from model.safeparse import yaml_load CACHE_DIR = upstream.CACHE_DIR diff --git a/scripts/scraper/romfolders/__main__.py b/scripts/scraper/romfolders/__main__.py index ad62ce559..5e36e2427 100644 --- a/scripts/scraper/romfolders/__main__.py +++ b/scripts/scraper/romfolders/__main__.py @@ -15,7 +15,7 @@ import yaml from . import Fetcher, SourceError, load_sources, scrape_setup from upstream import UpstreamError -from artifacts import write_text_atomic +from core.artifacts import write_text_atomic from ..base_scraper import _PlatformDumper DEFAULT_DIR = Path("platforms") / "romfolders" diff --git a/scripts/scraper/romfolders/es.py b/scripts/scraper/romfolders/es.py index a6f9d84be..b30c96418 100644 --- a/scripts/scraper/romfolders/es.py +++ b/scripts/scraper/romfolders/es.py @@ -31,7 +31,7 @@ import shlex from collections import Counter from collections.abc import Iterator -from safeparse import parse_untrusted_xml, yaml_load_upstream +from model.safeparse import parse_untrusted_xml, yaml_load_upstream from . import Fetcher, SourceError, register diff --git a/scripts/scraper/romset_dat_importer.py b/scripts/scraper/romset_dat_importer.py index e7a82e3dd..a5f36c521 100644 --- a/scripts/scraper/romset_dat_importer.py +++ b/scripts/scraper/romset_dat_importer.py @@ -51,7 +51,7 @@ from ..common import ( load_platform_config, run_cli, ) -from ..dumpcatalog import build_snapshot, load_provenance_snapshots, write_snapshot +from model.dumpcatalog import build_snapshot, load_provenance_snapshots, write_snapshot from .logiqx_parser import LogiqxDat, parse_logiqx MAX_MEMBER_SIZE = 200 * 1024 * 1024 diff --git a/scripts/scraper/targets/batocera_targets_scraper.py b/scripts/scraper/targets/batocera_targets_scraper.py index 1baa42311..411a47eeb 100644 --- a/scripts/scraper/targets/batocera_targets_scraper.py +++ b/scripts/scraper/targets/batocera_targets_scraper.py @@ -27,7 +27,7 @@ from datetime import datetime, timezone import yaml -from safeparse import yaml_load_upstream +from model.safeparse import yaml_load_upstream from . import BaseTargetScraper from ..base_scraper import github_headers diff --git a/scripts/sitebootstrap.py b/scripts/sitebootstrap.py index 5efca67d9..44b80bd42 100644 --- a/scripts/sitebootstrap.py +++ b/scripts/sitebootstrap.py @@ -21,7 +21,7 @@ import re import subprocess from pathlib import Path -from artifacts import write_if_changed +from core.artifacts import write_if_changed REPO_RAW = "https://raw.githubusercontent.com/Abdess/retrobios" SH_NAME = "i" diff --git a/scripts/siteguides.py b/scripts/siteguides.py index c2f312eb2..e9f948543 100644 --- a/scripts/siteguides.py +++ b/scripts/siteguides.py @@ -17,7 +17,7 @@ from dataclasses import dataclass, fields from pathlib import Path import sitemarkup as markup -from safeparse import require_yaml +from model.safeparse import require_yaml from sitebootstrap import PS1_NAME, SH_NAME PLATFORMS_DIR = Path(__file__).resolve().parent.parent / "platforms" diff --git a/scripts/sitehandheld.py b/scripts/sitehandheld.py index 36749d4f4..bf177d2ae 100644 --- a/scripts/sitehandheld.py +++ b/scripts/sitehandheld.py @@ -22,7 +22,7 @@ from dataclasses import dataclass, field from pathlib import Path import sitemarkup as markup -from artifacts import write_bytes_atomic +from core.artifacts import write_bytes_atomic from build_port import ARCHIVES, BATOCERA_ZIP, MUOS_APP, PORT_ZIP, TOOLS_ZIP, build_archive REPO_ROOT = Path(__file__).resolve().parent.parent diff --git a/scripts/sitemeasurements.py b/scripts/sitemeasurements.py index 44c6d2ea9..227b0b8ad 100644 --- a/scripts/sitemeasurements.py +++ b/scripts/sitemeasurements.py @@ -33,7 +33,7 @@ from pathlib import Path import measurement_records as mr import sitemarkup as markup -from artifacts import json_text, write_if_changed +from core.artifacts import json_text, write_if_changed from siterender import _escape_tags ROOT = Path(__file__).resolve().parent.parent diff --git a/scripts/siterender.py b/scripts/siterender.py index 38d6f4e26..70e28f895 100644 --- a/scripts/siterender.py +++ b/scripts/siterender.py @@ -447,7 +447,7 @@ def _read_arcade_source() -> tuple[dict, dict] | None: def _entry_archives(entry: dict, files: dict, by_name: dict) -> set[str]: """The archives of the collection a ``bios_zip`` entry names.""" - from ziptools import zip_member_crcs + from core.ziptools import zip_member_crcs crcs = { str(member["crc32"]).lower() diff --git a/scripts/sitewanted.py b/scripts/sitewanted.py index 208b6fc1a..fcd37c03c 100644 --- a/scripts/sitewanted.py +++ b/scripts/sitewanted.py @@ -24,9 +24,9 @@ from pathlib import Path import archive_build from common import runs_standalone, unique_emulator_profiles from cross_reference import _first_hash -from hashing import cut_md5_owner, parse_hash_list +from core.hashing import cut_md5_owner, parse_hash_list from validate_pr import LARGE_FILE_ISSUE_URL, Placement, placement -from validation import deliverable, filter_files_by_mode, installed_with_emulator +from resolve.validation import deliverable, filter_files_by_mode, installed_with_emulator ALGORITHMS = ("sha1", "sha256", "md5", "crc32") # GitHub's upload page takes 25 MB per file. A larger file goes in by a diff --git a/scripts/sitewrite.py b/scripts/sitewrite.py index 6a56560b6..95b4baf08 100644 --- a/scripts/sitewrite.py +++ b/scripts/sitewrite.py @@ -8,7 +8,7 @@ the clock alone.""" from __future__ import annotations from pathlib import Path -from artifacts import write_if_changed as _write_artifact +from core.artifacts import write_if_changed as _write_artifact import os # Every path this run produced. The generated directories used to be deleted # before the build, which made every page new: write_if_changed had no earlier diff --git a/scripts/slots.py b/scripts/slots.py index 66f22b63c..1b31adf82 100644 --- a/scripts/slots.py +++ b/scripts/slots.py @@ -24,7 +24,7 @@ import zlib from dataclasses import dataclass, field from typing import TYPE_CHECKING -import nativemode +from resolve import nativemode from common import ( compute_hashes, platform_arg, @@ -44,7 +44,7 @@ from common import ( variant_base_name, ) from packresolve import preferred_entries -from validation import ( +from resolve.validation import ( content_alternatives, outside_gap_scope, read_from_save_dir, diff --git a/scripts/split_pack.py b/scripts/split_pack.py index 3df3fe866..7ca4d5b36 100644 --- a/scripts/split_pack.py +++ b/scripts/split_pack.py @@ -28,7 +28,7 @@ import zipfile import zlib from pathlib import Path -from artifacts import ArtifactLockBusy, artifact_lock +from core.artifacts import ArtifactLockBusy, artifact_lock # "Each file included in a release must be under 2 GiB." ASSET_LIMIT = 2 * 1024**3 diff --git a/scripts/sync_release_assets.py b/scripts/sync_release_assets.py index 5498850a4..e67fd2871 100644 --- a/scripts/sync_release_assets.py +++ b/scripts/sync_release_assets.py @@ -36,12 +36,7 @@ from pathlib import Path sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) from check_release_assets import compare, expected_assets, expected_digests, fetch_release from common import load_database -from largefiles import ( - LARGE_FILES_RELEASE, - LARGE_FILES_REPO, - asset_names, - registered_paths, -) +from model.largefiles import LARGE_FILES_RELEASE, LARGE_FILES_REPO, asset_names, registered_paths STAGING = Path("tmp") / "sync_release_assets" OUT_OF_DATE = ("missing", "size", "content") diff --git a/scripts/upstream.py b/scripts/upstream.py index 6c9b9133f..bfd7c4bb7 100644 --- a/scripts/upstream.py +++ b/scripts/upstream.py @@ -25,7 +25,7 @@ from dataclasses import dataclass from datetime import datetime from pathlib import Path -from artifacts import set_plain_mode +from core.artifacts import set_plain_mode USER_AGENT = "retrobios-profile-sync/1.0" # Where fetched upstream files live, shared by every reader of this cache. diff --git a/scripts/validate_pr.py b/scripts/validate_pr.py index ab88b819e..02c631d8f 100644 --- a/scripts/validate_pr.py +++ b/scripts/validate_pr.py @@ -45,10 +45,10 @@ from common import ( parse_md5_list, require_directory, ) -from hashing import parse_hash_list -from nativemode import digest_algorithm +from core.hashing import parse_hash_list +from resolve.nativemode import digest_algorithm from dedup import _in_nodedup_dir -from validation import frontend_digest_matches, inner_rom_check +from resolve.validation import frontend_digest_matches, inner_rom_check try: import yaml diff --git a/scripts/validate_schemas.py b/scripts/validate_schemas.py index b50923a0e..aa5845228 100644 --- a/scripts/validate_schemas.py +++ b/scripts/validate_schemas.py @@ -207,7 +207,7 @@ def _group_requirement_split(path: Path, document: object) -> list[str]: that can contradict the first: a true on the first name only wrote the search order into required, and the other names read as optional. """ - from alternatives import groups_of + from model.alternatives import groups_of if not isinstance(document, dict): return [] @@ -558,7 +558,7 @@ def _save_dir_without_library_name(path: Path, document: object) -> list[str]: (sort_savefiles_enable): without the name, packs and the installer cannot say where the file goes, and leave it out. """ - from validation import read_from_save_dir + from resolve.validation import read_from_save_dir if not isinstance(document, dict): return [] @@ -581,7 +581,7 @@ def _save_folder_once_paths(path: Path, document: dict) -> list[str]: frontend sorts saves by core or not, which holds only when the path already names the folder the core reads below. """ - from validation import read_from_save_dir + from resolve.validation import read_from_save_dir if not document.get("save_folder_once"): return [] diff --git a/scripts/verify.py b/scripts/verify.py index e8ae68319..96bed7d33 100644 --- a/scripts/verify.py +++ b/scripts/verify.py @@ -38,8 +38,8 @@ from typing import TYPE_CHECKING, TypedDict import slots sys.path.insert(0, os.path.dirname(__file__)) -from hashing import parse_md5_list -from alternatives import ( +from core.hashing import parse_md5_list +from model.alternatives import ( core_file_spares, set_fields, set_keys, @@ -102,17 +102,17 @@ from common import ( system_dir_path, ) -from exporter.candidates import BIOS, EntryCategories -from launchers import LauncherLayer, declared_destinations, held_record, launcher_unproven +from resolve.categories import BIOS, EntryCategories +from resolve.launchers import LauncherLayer, declared_destinations, held_record, launcher_unproven from cross_reference import launcher_reads_not_held -from nativemode import ( +from resolve.nativemode import ( SIZE_AND_ANY_HASH, digest_algorithm, hash_mismatch_excludes_file, normalize as normalize_mode, reads_file_contents, ) -from validation import ( +from resolve.validation import ( baseline_verdict, case_folded_slots, declaration_settles, @@ -1626,7 +1626,7 @@ def _cut_game_data( system_filter: list[str] | None, ) -> tuple[dict, dict, list[str]]: """The config and profiles of a --no-game-data pack, and what it leaves out.""" - from gamedata import without_game_data + from resolve.gamedata import without_game_data if emu_profiles is None: emu_profiles = load_emulator_profiles(emulators_dir) diff --git a/tests/test_agnostic_substitute.py b/tests/test_agnostic_substitute.py index bc0083c4e..c0ee105d6 100644 --- a/tests/test_agnostic_substitute.py +++ b/tests/test_agnostic_substitute.py @@ -14,7 +14,7 @@ import tempfile import unittest from pathlib import Path -from validation import agnostic_substitute +from resolve.validation import agnostic_substitute REPO_ROOT = Path(__file__).resolve().parents[1] diff --git a/tests/test_archive_recipes.py b/tests/test_archive_recipes.py index 0345fbc7d..20248a3f0 100644 --- a/tests/test_archive_recipes.py +++ b/tests/test_archive_recipes.py @@ -159,7 +159,7 @@ class HeldArchivesMatchTheirRecipes(unittest.TestCase): if not bios.is_dir() or not (REPO_ROOT / "recipes").is_dir(): self.skipTest("bios/ or recipes/ is not present") from common import variant_base_name - from hashing import md5_composite_of + from core.hashing import md5_composite_of allowed = _allowed_members() pinned, zipped = _platform_pins() diff --git a/tests/test_artifact_lock.py b/tests/test_artifact_lock.py index f8cf08fbe..6e757164b 100644 --- a/tests/test_artifact_lock.py +++ b/tests/test_artifact_lock.py @@ -25,7 +25,7 @@ from common import ( publish_hold, ) from tests.scratchtree import scratch_checkout -import artifacts +from core import artifacts from unittest import mock REPO_ROOT = Path(__file__).resolve().parent.parent diff --git a/tests/test_atomic_artifacts.py b/tests/test_atomic_artifacts.py index 7123be45a..32502d045 100644 --- a/tests/test_atomic_artifacts.py +++ b/tests/test_atomic_artifacts.py @@ -17,7 +17,7 @@ import unittest from pathlib import Path from unittest import mock -import artifacts +from core import artifacts REPO_ROOT = Path(__file__).resolve().parent.parent diff --git a/tests/test_audit_regressions.py b/tests/test_audit_regressions.py index 4bd9eb283..f8b70a69a 100644 --- a/tests/test_audit_regressions.py +++ b/tests/test_audit_regressions.py @@ -28,7 +28,8 @@ try: except ImportError: jsonschema = None import install -from scripts import pipeline, region, region_audit +from scripts import pipeline, region_audit +from scripts import region from scripts.common import resolve_local_file, safe_extract_zip from scripts.generate_pack import ( _emulator_region_group, @@ -1424,7 +1425,7 @@ class OneBaselineVerdict(unittest.TestCase): return str(path) def test_a_missing_member_is_refused_whatever_the_outer_status(self): - from scripts.validation import baseline_verdict + from scripts.resolve.validation import baseline_verdict entry = {"name": "dragon32.zip", "zipped_file": "d32.rom", "md5": ""} with tempfile.TemporaryDirectory(dir=TMP_ROOT) as directory: @@ -1466,7 +1467,7 @@ class OneBaselineVerdict(unittest.TestCase): import hashlib from scripts.common import md5_composite - from scripts.validation import baseline_verdict, digest_verdict + from scripts.resolve.validation import baseline_verdict, digest_verdict with tempfile.TemporaryDirectory(dir=TMP_ROOT) as directory: loose = Path(directory) / "abc.bin" @@ -1496,7 +1497,7 @@ class OneBaselineVerdict(unittest.TestCase): import hashlib from scripts.common import md5_composite - from scripts.validation import digest_verdict + from scripts.resolve.validation import digest_verdict with tempfile.TemporaryDirectory(dir=TMP_ROOT) as directory: archive = self._archive(Path(directory), "rom.bin") @@ -3611,7 +3612,7 @@ class TheZipIndexCacheKnowsItsInputs(unittest.TestCase): got the first call's index back.""" def test_the_bound_and_the_sha1_are_part_of_the_key(self): - from scripts import ziptools + from scripts.core import ziptools with tempfile.TemporaryDirectory(dir=TMP_ROOT) as directory: path = Path(directory) / "a.zip" @@ -3760,7 +3761,7 @@ class KidVidTapesStayWithTheContent(unittest.TestCase): def test_no_pack_places_them_in_the_system_directory(self): from scripts.common import load_emulator_profiles - from scripts.validation import ( + from scripts.resolve.validation import ( outside_gap_scope, read_from_save_dir, read_from_system_dir, @@ -3985,7 +3986,7 @@ class ADataDirectoryIsWalkedOnce(unittest.TestCase): walks.append(top) return real_walk(top, *a, **k) - with mock.patch.object(common.os, "walk", counting_walk): + with mock.patch.object(os, "walk", counting_walk): first, _ = common._resolve_in_data_dirs(["font.bin"], registry, lambda _p: "name_exact") second, _ = common._resolve_in_data_dirs(["other.bin"], registry, @@ -4002,7 +4003,7 @@ class ADuplicateYamlKeyIsRefused(unittest.TestCase): target_source keys for Recalbox and nothing noticed.""" def test_the_loader_names_the_repeated_key(self): - from safeparse import yaml_load + from model.safeparse import yaml_load with self.assertRaises(yaml.constructor.ConstructorError) as caught: yaml_load("platform: x\ntarget_source: a\ntarget_source: b\n") @@ -4965,7 +4966,7 @@ class AZipMemberIsHashedOnce(unittest.TestCase): every step: 4 788 times for 355 members in verify --all.""" def test_repeated_questions_read_the_archive_once(self): - from scripts import ziptools + from scripts.core import ziptools with tempfile.TemporaryDirectory(dir=TMP_ROOT) as tmp: archive = Path(tmp, "set.zip") @@ -5048,7 +5049,7 @@ class SignaturesCarryTheirTypes(unittest.TestCase): # Lowered as modules are annotated, never raised. CEILING = 0 - COMPLETE = ("artifacts.py", "common.py", "validation.py", "generate_pack.py") + COMPLETE = ("core/artifacts.py", "common.py", "resolve/validation.py", "generate_pack.py") @staticmethod def _missing(path: Path) -> list[str]: @@ -5080,7 +5081,8 @@ class ATreeNobodyHoldsIsMissingNotAnAsset(unittest.TestCase): IsADirectoryError where verify said MISSING.""" def test_directory_entries_never_reach_the_asset_store(self): - from scripts import largefiles, packresolve + from scripts.model import largefiles + from scripts import packresolve db = {"files": {}, "indexes": {"by_name": {}, "by_md5": {}, "by_crc32": {}, "by_path_suffix": {}}} @@ -5394,7 +5396,7 @@ class BundledFilesAreNotToSource(unittest.TestCase): def test_a_build_scope_keeps_it_for_the_other_build(self): """PPSSPP's standalone release ships assets/, its libretro core does not: bundled for one build, the entry still reaches a core's pack.""" - from validation import deliverable + from resolve.validation import deliverable entries = [{"ref": "ppsspp-assets", "mode": "libretro"}, {"name": "a.bin", "bundled": True, "mode": "standalone"}, @@ -5406,7 +5408,7 @@ class BundledFilesAreNotToSource(unittest.TestCase): def test_a_platform_package_can_differ_both_ways(self): """Batocera's hcl package installs the binary alone, its blueMSX core package copies the machines beside the core.""" - from validation import installed_with_emulator + from resolve.validation import installed_with_emulator hcl = {"name": "data.pak", "bundled": True, "not_bundled_on": ["batocera"]} machines = {"name": "Machines/MSX/config.ini", "installed_on": ["batocera", "retropie"]} @@ -5900,7 +5902,7 @@ class ZippedFileMd5IsParsedOnce(unittest.TestCase): import hashlib import zipfile as zf_mod - from scripts.validation import inner_rom_check + from scripts.resolve.validation import inner_rom_check from scripts.verify import verify_entry_md5 with tempfile.TemporaryDirectory(dir=TMP_ROOT) as directory: @@ -5917,7 +5919,7 @@ class ZippedFileMd5IsParsedOnce(unittest.TestCase): ) def test_the_three_sites_share_the_parser(self): - for module in ("validation.py", "packverify.py", "verify.py"): + for module in ("resolve/validation.py", "packverify.py", "verify.py"): source = (ROOT / "scripts" / module).read_text() self.assertIn("parse_md5_list(", source, module) @@ -5930,7 +5932,7 @@ class AHashListIsReadOneWay(unittest.TestCase): def test_every_reader_splits_the_list(self): from scripts.cross_reference import _declared_content - from scripts.hashing import parse_hash_list + from scripts.core.hashing import parse_hash_list from scripts.profile_sync import entry_hashes a, b = "a" * 64, "B" * 64 @@ -6359,7 +6361,7 @@ class FsUaeKickstartIsFoundByContent(unittest.TestCase): flag came from the RetroPie launcher, which the platform layer records.""" def test_the_kickstart_is_an_optional_label(self): - from scripts.validation import opens_by_name + from scripts.resolve.validation import opens_by_name profile = yaml.safe_load((ROOT / "emulators" / "fs-uae.yml").read_text(encoding="utf-8")) entry = next(f for f in profile["files"] if f.get("sha1") == "891e9a547772fe0c6c19b610baf8bc4ea7fcb785") @@ -6923,7 +6925,7 @@ class AHashConflictIsReportedOnce(unittest.TestCase): import contextlib import io - import truth + from resolve import truth truth._CONFLICTS_SHOWN.clear() err = io.StringIO() @@ -7063,7 +7065,7 @@ class AFileTheLauncherNeverOpens(unittest.TestCase): as required and missing on RetroBat although nothing there opens them.""" def test_unread_on_drops_the_entry_for_that_platform_only(self): - from validation import deliverable, unread_on + from resolve.validation import deliverable, unread_on entry = {"name": "cdbios.bin", "unread_on": ["retrobat"]} self.assertTrue(unread_on(entry, "retrobat")) @@ -7650,7 +7652,7 @@ class Ps2BiosImagesAreFoundByContent(unittest.TestCase): name armsx2 opens on six platforms.""" import yaml - from validation import opens_by_name + from resolve.validation import opens_by_name named = [] for path in sorted((ROOT / "emulators").glob("*.yml")): @@ -7680,7 +7682,7 @@ class SynthRomsAreFoundByContent(unittest.TestCase): def test_every_synth_rom_is_marked(self): import yaml - from validation import opens_by_name + from resolve.validation import opens_by_name profile = yaml.safe_load( (ROOT / "emulators" / "dosbox-staging.yml").read_text(encoding="utf-8") @@ -7727,7 +7729,7 @@ class OpenMsxSystemRomsAreFoundBySha1(unittest.TestCase): def test_no_systemrom_label_reads_as_a_name(self): import yaml - from validation import opens_by_name + from resolve.validation import opens_by_name profile = yaml.safe_load((ROOT / "emulators" / "openmsx.yml").read_text()) named = [ diff --git a/tests/test_batocera_cores.py b/tests/test_batocera_cores.py index 03eceb66c..4e867d616 100644 --- a/tests/test_batocera_cores.py +++ b/tests/test_batocera_cores.py @@ -113,7 +113,7 @@ class AnEmulatorLaunchedBothWaysGetsBothLayouts(unittest.TestCase): def test_upstream_yaml_is_read_as_its_code_reads_it(self): """configgen-defaults.yml names rtcw's core twice. The strict loader stopped the rescrape, while Batocera's PyYAML keeps the last value.""" - from safeparse import yaml_load_upstream + from model.safeparse import yaml_load_upstream self.assertEqual( yaml_load_upstream("rtcw:\n core: iortcw\n core: taradino\n"), diff --git a/tests/test_batocera_md5_list.py b/tests/test_batocera_md5_list.py index be52a9288..19e6b6ada 100644 --- a/tests/test_batocera_md5_list.py +++ b/tests/test_batocera_md5_list.py @@ -20,7 +20,7 @@ from pathlib import Path from common import resolve_local_file from exporter import discover_exporters from export_native import landed_changes -from exporter.baseline import NativeFile, build_native_model +from resolve.reconcile import NativeFile, build_native_model from exporter.batocera_exporter import md5_list_support from scraper import rocknix_scraper from scraper.base_scraper import md5_field, requirement_entry diff --git a/tests/test_cited_lines.py b/tests/test_cited_lines.py index d3c77d6a3..63c0ff779 100644 --- a/tests/test_cited_lines.py +++ b/tests/test_cited_lines.py @@ -14,7 +14,7 @@ import unittest from pathlib import Path import upstream -from safeparse import yaml_load +from model.safeparse import yaml_load ROOT = Path(__file__).resolve().parents[1] diff --git a/tests/test_content_checks.py b/tests/test_content_checks.py index 1e99a62e0..7ffd40b58 100644 --- a/tests/test_content_checks.py +++ b/tests/test_content_checks.py @@ -22,8 +22,8 @@ from pathlib import Path import common import generate_pack as builder import packextras -from romdir import romdir_accepts, walk -from validation import _build_validation_index, check_file_validation +from core.romdir import romdir_accepts, walk +from resolve.validation import _build_validation_index, check_file_validation REPO_ROOT = Path(__file__).resolve().parent.parent diff --git a/tests/test_content_declarations.py b/tests/test_content_declarations.py index 2c9db3e60..92310a661 100644 --- a/tests/test_content_declarations.py +++ b/tests/test_content_declarations.py @@ -13,7 +13,7 @@ import tests import unittest from common import platform_declared_contents -from validation import declaration_settles +from resolve.validation import declaration_settles SHA1 = "70cdf57469a208528f78a14275837352e90e20f1" DB = { diff --git a/tests/test_core_data_trees.py b/tests/test_core_data_trees.py index db3c13278..3431462bd 100644 --- a/tests/test_core_data_trees.py +++ b/tests/test_core_data_trees.py @@ -18,7 +18,7 @@ from pathlib import Path import common import generate_pack as builder -from validation import deliverable, read_from_system_dir +from resolve.validation import deliverable, read_from_system_dir REPO_ROOT = Path(__file__).resolve().parent.parent diff --git a/tests/test_core_size_refusal.py b/tests/test_core_size_refusal.py index 78ae6f59a..1df8b6a8d 100644 --- a/tests/test_core_size_refusal.py +++ b/tests/test_core_size_refusal.py @@ -24,7 +24,7 @@ import yaml import common import generate_db import generate_pack as builder -from validation import core_size_refusal +from resolve.validation import core_size_refusal from verify import find_undeclared_files, verify_platform REPO_ROOT = Path(__file__).resolve().parent.parent diff --git a/tests/test_crypto_aes.py b/tests/test_crypto_aes.py index bd372c456..4e6ea15a6 100644 --- a/tests/test_crypto_aes.py +++ b/tests/test_crypto_aes.py @@ -13,11 +13,11 @@ import ast import unittest from pathlib import Path -import crypto_verify +from core import crypto_verify REPO_ROOT = Path(__file__).resolve().parents[1] -STDLIB_OR_LOCAL = {"__future__", "hashlib", "struct", "collections", "pathlib", "sect233r1"} +STDLIB_OR_LOCAL = {"__future__", "hashlib", "struct", "collections", "pathlib", "core"} class StdlibAes(unittest.TestCase): @@ -40,7 +40,7 @@ class StdlibAes(unittest.TestCase): ) def test_no_third_party_import(self): - tree = ast.parse((REPO_ROOT / "scripts" / "crypto_verify.py").read_text()) + tree = ast.parse((REPO_ROOT / "scripts" / "core" / "crypto_verify.py").read_text()) modules = { (node.module if isinstance(node, ast.ImportFrom) else alias.name).split(".")[0] for node in ast.walk(tree) diff --git a/tests/test_crypto_unique_data.py b/tests/test_crypto_unique_data.py index 3b09c0780..5ef7ddf17 100644 --- a/tests/test_crypto_unique_data.py +++ b/tests/test_crypto_unique_data.py @@ -26,8 +26,8 @@ import tempfile import unittest from pathlib import Path -import crypto_verify -import sect233r1 as ec +from core import crypto_verify +from core import sect233r1 as ec # A 2048-bit RSA key, the size the 3DS signatures use, from two fixed primes # so the fixture is reproducible and costs nothing to build. diff --git a/tests/test_crypto_verify.py b/tests/test_crypto_verify.py index b6dd83a30..048008150 100644 --- a/tests/test_crypto_verify.py +++ b/tests/test_crypto_verify.py @@ -23,8 +23,8 @@ import unittest import unittest.mock from pathlib import Path -import crypto_verify -import sect233r1 as ec +from core import crypto_verify +from core import sect233r1 as ec class FieldArithmetic(unittest.TestCase): diff --git a/tests/test_deterministic_zip.py b/tests/test_deterministic_zip.py index 2dc59fed0..77f6c0453 100644 --- a/tests/test_deterministic_zip.py +++ b/tests/test_deterministic_zip.py @@ -12,7 +12,7 @@ import unittest import zipfile from pathlib import Path -from scripts.deterministic_zip import ( +from scripts.core.deterministic_zip import ( _FIXED_DATE_TIME, rebuild_zip_deterministic, verify_zip_determinism, diff --git a/tests/test_doc_pages.py b/tests/test_doc_pages.py index f4aa2d923..d6bf86074 100644 --- a/tests/test_doc_pages.py +++ b/tests/test_doc_pages.py @@ -445,7 +445,7 @@ class Md5CompositeDefinition(unittest.TestCase): members' contents in name order.""" def test_page_and_code_agree(self): - from hashing import md5_composite_of + from core.hashing import md5_composite_of buffer = io.BytesIO() with zipfile.ZipFile(buffer, "w") as zf: @@ -461,7 +461,7 @@ class Md5CompositeDefinition(unittest.TestCase): """The page said the direct MD5 is tried before the composite, which Recalbox never does for a .zip, and the pack check did the same.""" import common - import validation + from resolve import validation section = _section(_page("verification-modes.md"), "md5_composite (Recalbox ZIP verification)") self.assertIn("zip_digest: composite", section) @@ -1855,7 +1855,7 @@ class CrossReferenceSettlesBySlotAndSize(unittest.TestCase): settles a file only at its slot or at a size the core accepts.""" def test_the_page_states_the_rule_verify_reads(self): - from validation import declaration_settles + from resolve.validation import declaration_settles rom1 = {"name": "ROM1.BIN", "size": 32768, "validation": ["size"]} self.assertFalse(declaration_settles(rom1, "ROM1.BIN", {"ROM1.BIN": [(4096, "rom1.bin")]}, @@ -1953,7 +1953,7 @@ class TheRemovalProofsAreTheExportersOwn(unittest.TestCase): "data_directory": "a data directory"} def test_the_page_names_each_proof_in_order(self): - from exporter.candidates import _PROOF_ORDER + from resolve.categories import _PROOF_ORDER page = (WIKI / "tools.md").read_text(encoding="utf-8") start = page.index("No entry the platform declares is removed.") diff --git a/tests/test_e2e.py b/tests/test_e2e.py index e579f6777..a1684513d 100644 --- a/tests/test_e2e.py +++ b/tests/test_e2e.py @@ -31,7 +31,7 @@ import zipfile from pathlib import Path from unittest import mock -import largefiles +from model import largefiles import yaml from common import ( build_zip_contents_index, @@ -47,12 +47,8 @@ from common import ( resolve_platform_cores, safe_extract_zip, ) -from truth import diff_platform_truth, generate_platform_truth -from validation import ( - _build_validation_index, - check_file_validation, - filter_files_by_mode, -) +from resolve.truth import diff_platform_truth, generate_platform_truth +from resolve.validation import _build_validation_index, check_file_validation, filter_files_by_mode from verify import ( Severity, Status, @@ -2087,7 +2083,7 @@ class TestE2E(unittest.TestCase): def test_112_build_ground_truth(self): """build_ground_truth returns per-emulator detail for a filename.""" - from validation import build_ground_truth + from resolve.validation import build_ground_truth profiles = load_emulator_profiles(self.emulators_dir) index = _build_validation_index(profiles) @@ -2104,7 +2100,7 @@ class TestE2E(unittest.TestCase): def test_113_build_ground_truth_empty(self): """build_ground_truth returns [] for unknown filename.""" - from validation import build_ground_truth + from resolve.validation import build_ground_truth profiles = load_emulator_profiles(self.emulators_dir) index = _build_validation_index(profiles) @@ -4198,7 +4194,7 @@ class TestE2E(unittest.TestCase): def test_104_diff_truth_normalized_system_ids(self): """Diff matches systems with different ID formats via normalization.""" - from truth import diff_platform_truth + from resolve.truth import diff_platform_truth truth = { "systems": { @@ -4313,7 +4309,7 @@ class TestE2E(unittest.TestCase): }, } - from exporter.baseline import build_native_model + from resolve.reconcile import build_native_model systems, report = build_native_model(truth, scraped) exporter = SystemDatExporter() @@ -4354,7 +4350,7 @@ class TestE2E(unittest.TestCase): }, } - from exporter.baseline import build_native_model + from resolve.reconcile import build_native_model systems, report = build_native_model(truth, {"systems": {}}) original = ('clrmamepro (\n\tname "System"\n)\n\ngame (\n\tname "System"\n' @@ -4568,7 +4564,7 @@ class TestE2E(unittest.TestCase): def test_177_diff_hash_fallback_rename(self): """Diff detects platform renames via hash fallback.""" - from truth import diff_platform_truth + from resolve.truth import diff_platform_truth truth = { "systems": { @@ -4603,7 +4599,7 @@ class TestE2E(unittest.TestCase): def test_178_diff_system_normalization(self): """Diff matches systems with different IDs via normalization.""" - from truth import diff_platform_truth + from resolve.truth import diff_platform_truth truth = { "systems": { @@ -4738,7 +4734,7 @@ class TestE2E(unittest.TestCase): "sony-playstation": {"native_id": "psx", "files": []}, }, } - from exporter.baseline import build_native_model + from resolve.reconcile import build_native_model # The systems dict is one block inside the checker Batocera runs, so # the exporter is handed the script it patches. @@ -4789,7 +4785,7 @@ class TestE2E(unittest.TestCase): "sony-playstation": {"native_id": "psx", "files": []}, }, } - from exporter.baseline import build_native_model + from resolve.reconcile import build_native_model systems, report = build_native_model(truth, scraped) exp = Exporter() @@ -4832,7 +4828,7 @@ class TestE2E(unittest.TestCase): "sony-playstation": {"native_id": "psx", "files": []}, } } - from exporter.baseline import build_native_model + from resolve.reconcile import build_native_model systems, report = build_native_model(truth, scraped) exp = Exporter() @@ -6958,7 +6954,7 @@ class OneOfASearchList(unittest.TestCase): self.assertEqual(report["seq"]["set_aside"]["other_versions"], 2) def test_truth_names_no_member_required_on_its_own(self): - from truth import _fold_into, _new_truth_entry + from resolve.truth import _fold_into, _new_truth_entry entry = _new_truth_entry(dict(self.profile["files"][0]), "seq", None) self.assertNotIn("required", entry) @@ -6971,7 +6967,7 @@ class OneOfASearchList(unittest.TestCase): def test_ranks_order_one_set_and_never_two(self): """px68k-sdl ranks its IPL list and its font list each from 1: --one-per-slot keeps the first of each, not one file of the two.""" - from slot import build_slot_index, resolve_slot_drops + from resolve.slot import build_slot_index, resolve_slot_drops profile = {"type": "standalone", "files": [ {"name": "ipl_a.dat", "group": "ipl", "priority": 1}, @@ -7023,7 +7019,7 @@ class OneOfASearchList(unittest.TestCase): """pom2 falls back on apple2e.rom for the //e it boots by default and for the unenhanced //e it may be switched to. One value on the file cannot say both: the sets carry it.""" - from alternatives import derive_member_requirements + from model.alternatives import derive_member_requirements profile = {"groups": {"iie": {"required": True}, "iie-u": {"required": False}}, "files": [{"name": "apple2e_unenh.rom", "group": "iie-u"}, @@ -7051,7 +7047,7 @@ class OneOfASearchList(unittest.TestCase): self.assertEqual(packed, held) def test_required_only_core_files_keep_one_member(self): - from alternatives import core_file_spares + from model.alternatives import core_file_spares undeclared = find_undeclared_files( self.config, "emulators", self.db, {"seq": self.profile} diff --git a/tests/test_elec_scrapers.py b/tests/test_elec_scrapers.py index a58dfd5d2..1e65e9512 100644 --- a/tests/test_elec_scrapers.py +++ b/tests/test_elec_scrapers.py @@ -271,7 +271,7 @@ class TheExportKeepsTheirShape(unittest.TestCase): def test_paths_start_where_the_list_starts(self): from exporter.amberelec_exporter import Exporter as Amber - from exporter.baseline import NativeFile + from resolve.reconcile import NativeFile from exporter.knulli_exporter import Exporter as Knulli fe = NativeFile("neogeo.zip", "neogeo/neogeo.zip", "neogeo") diff --git a/tests/test_entry_categories.py b/tests/test_entry_categories.py index 4f58ecd7f..b3df55d1b 100644 --- a/tests/test_entry_categories.py +++ b/tests/test_entry_categories.py @@ -11,14 +11,7 @@ import tests import unittest import verify -from exporter.candidates import ( - BIOS, - GAME_DATA, - UNREAD, - EntryCategories, - ProofIndex, - ReadEvidence, -) +from resolve.categories import BIOS, GAME_DATA, UNREAD, EntryCategories, ProofIndex, ReadEvidence PROFILES = { "bluemsx": { @@ -48,7 +41,7 @@ class EachProfileEntryIsHashedOnce(unittest.TestCase): def test_two_platform_entries_read_one_profile_entry_once(self): from unittest import mock - import exporter.candidates as candidates + from resolve import categories as candidates profiles = {"core": {"emulator": "Core", "type": "libretro", "cores": ["core"], "systems": ["s"], diff --git a/tests/test_export_counts.py b/tests/test_export_counts.py index c59b37789..5c0812eb2 100644 --- a/tests/test_export_counts.py +++ b/tests/test_export_counts.py @@ -16,7 +16,7 @@ import unittest from collections import OrderedDict from pathlib import Path -from exporter.baseline import NativeFile, NativeSystem, Report, build_native_model +from resolve.reconcile import NativeFile, NativeSystem, Report, build_native_model from exporter.bizhawk_exporter import Exporter as BizHawk from exporter.misterfpga_exporter import Exporter as Mister from exporter.romm_exporter import Exporter as Romm @@ -191,7 +191,7 @@ class RetroBatKeepsWhatWeDoNotModel(unittest.TestCase): ]}, "newsys": {"name": "New", "biosFiles": [{"md5": B, "file": "bios/new.bin"}]}, } - from exporter.baseline import Report + from resolve.reconcile import Report produced = json.loads(RetroBat().render( systems, Report(), {"batocera-systems.json": json.dumps(original)}, @@ -251,7 +251,7 @@ class PureDataExportsKeepWhatWeDoNotModel(unittest.TestCase): filled=[]) def test_recalbox(self): - from exporter.baseline import Report + from resolve.reconcile import Report from exporter.recalbox_exporter import Exporter as Recalbox fe = self._file("a.bin", "nes", destination="nes/a.bin", core="libretro:fceumm") @@ -277,7 +277,7 @@ class PureDataExportsKeepWhatWeDoNotModel(unittest.TestCase): self.assertIn('mandatory="false"', produced) def test_system_dat(self): - from exporter.baseline import Report + from resolve.reconcile import Report fe = self._file("a.bin", "Nintendo - NES") systems = {"Nintendo - NES": NativeSystem("Nintendo - NES", files=[fe])} @@ -301,7 +301,7 @@ class PureDataExportsKeepWhatWeDoNotModel(unittest.TestCase): def test_two_additions_differing_by_directory_are_two_lines(self): """PCSX2's vulkan and opengl convert.glsl were both written under the bare name, so the second was dropped and still counted as added.""" - from exporter.baseline import Report + from resolve.reconcile import Report shaders = [ NativeFile("convert.glsl", f"pcsx2/resources/shaders/{api}/convert.glsl", @@ -977,7 +977,7 @@ class TheSummaryCountsWhatTheFileCarries(unittest.TestCase): def test_romm_drops_the_hashes_it_counts_cleared(self): from export_native import landed_changes - from exporter.baseline import Report + from resolve.reconcile import Report fe = self._contradicted() systems = {"psx": NativeSystem("psx", files=[fe])} diff --git a/tests/test_export_report.py b/tests/test_export_report.py index 13f277a9b..496ec375f 100644 --- a/tests/test_export_report.py +++ b/tests/test_export_report.py @@ -317,7 +317,7 @@ class ReportedChangesAreTheDiff(unittest.TestCase): def _run(self, platform: str, filename: str) -> tuple[list[dict], str, str, dict]: from common import load_platform_config, native_layer from exporter import discover_exporters - from exporter.baseline import build_native_model + from resolve.reconcile import build_native_model original_path = UPSTREAM_CACHE / platform / filename if not original_path.is_file(): @@ -394,7 +394,7 @@ class ReportedChangesAreTheDiff(unittest.TestCase): report counted every file a profiled core reads as added.""" from common import load_platform_config, native_layer from exporter import discover_exporters - from exporter.baseline import build_native_model + from resolve.reconcile import build_native_model archive = UPSTREAM_CACHE / "retropie" / "RetroPie-Setup.tar.gz" if not archive.is_file(): @@ -492,8 +492,8 @@ class RemovalCandidatesNeedAReadingNoCoreAnswers(unittest.TestCase): } def _candidates(self, files: list[dict], cores: list[str] | None = None) -> list[dict]: - from exporter.baseline import build_native_model - from exporter.candidates import removal_candidates + from resolve.reconcile import build_native_model + from resolve.categories import removal_candidates scraped = self._scraped(files, cores or ["corea"]) systems, _ = build_native_model({"systems": {}}, scraped) @@ -506,8 +506,8 @@ class RemovalCandidatesNeedAReadingNoCoreAnswers(unittest.TestCase): """Batocera's DuckStation generator walks 22 names (bios_lists, duckstationGenerator.py:501-515): a name it opens is read on Batocera whatever the profiles call it.""" - from exporter.baseline import build_native_model - from exporter.candidates import removal_candidates + from resolve.reconcile import build_native_model + from resolve.categories import removal_candidates scraped = self._scraped([{"name": "scph7502.bin"}], ["corea"]) scraped["launchers"] = [{ diff --git a/tests/test_exporters.py b/tests/test_exporters.py index ae1781815..aaef93213 100644 --- a/tests/test_exporters.py +++ b/tests/test_exporters.py @@ -46,12 +46,7 @@ from export_native import ( pinned_base, source_key, ) -from exporter.baseline import ( - NativeFile, - NativeSystem, - Report, - build_native_model, -) +from resolve.reconcile import NativeFile, NativeSystem, Report, build_native_model REPO_ROOT = Path(__file__).resolve().parent.parent @@ -342,7 +337,7 @@ class Reconciliation(unittest.TestCase): line for LRPS2 as a hash and size correction.""" import contextlib - import truth as truth_module + from resolve import truth as truth_module entry = {"name": "GameIndex.yaml", "sha1": "1" * 40, "size": 2690355} with contextlib.redirect_stderr(io.StringIO()): @@ -361,7 +356,7 @@ class Reconciliation(unittest.TestCase): self.assertEqual(report.hashes_corrected, []) def test_the_diff_names_no_mismatch_the_code_does_not_check(self): - from truth import _diff_system + from resolve.truth import _diff_system truth_sys = {"files": [{"name": "scph1001.bin", "md5": "a" * 32, "validation": ["size"]}]} scraped_sys = {"files": [{"name": "scph1001.bin", "md5": "b" * 32}]} @@ -405,7 +400,7 @@ class Reconciliation(unittest.TestCase): self.assertEqual(report.hashes_corrected, []) def test_the_diff_names_no_missing_label(self): - from truth import _diff_system + from resolve.truth import _diff_system truth_sys = {"files": [{"name": "scph1001_v20.bin", "md5": "a" * 32, "_cores": ["duckstation"], "_named_by": []}]} self.assertNotIn("missing", _diff_system(truth_sys, {"files": []})) @@ -446,7 +441,7 @@ class Reconciliation(unittest.TestCase): self.assertEqual(added.runners, [(False, "armsx2")]) def test_the_diff_names_no_missing_bundled_file(self): - from truth import _diff_system + from resolve.truth import _diff_system truth_sys = {"files": [{"name": "gngeo_data.zip", "md5": "a" * 32, "bundled": True, "_cores": ["gngeopi"], "_named_by": ["gngeopi"], "_brought_by": []}]} @@ -455,7 +450,7 @@ class Reconciliation(unittest.TestCase): def test_the_diff_pairs_by_the_same_rule(self): """diff_truth reads the same pairing, or it names a mismatch the export does not correct.""" - from truth import _diff_system + from resolve.truth import _diff_system truth_sys = {"files": [ {"name": "system.rom", "aliases": ["bios.rom"], "md5": "c" * 32}, {"name": "bios.rom", "path": "np2kai/bios.rom"}, @@ -766,7 +761,7 @@ class SearchOrder(unittest.TestCase): """PicoDrive loads the first file of each region's list. RetroPie names one per region, but the export appended three more, which the sentence reads as three more required files.""" - from exporter.baseline import NativeSystem + from resolve.reconcile import NativeSystem def cd(name, region, rank): return NativeFile(name=name, destination=name, native_system="segacd", truth={ @@ -799,7 +794,7 @@ class SearchOrder(unittest.TestCase): """flycast's help names the Dreamcast BIOS, then the Naomi/Atomiswave ones. naomi2.zip, an arcade archive, went into the Dreamcast list: only the first BIOS clause was read.""" - from exporter.baseline import NativeSystem + from resolve.reconcile import NativeSystem def entry(name, system): return NativeFile(name=name, destination=f"dc/{name}", native_system=system, @@ -2814,7 +2809,7 @@ class ARecordDescribesOneDump(unittest.TestCase): export wrote v2.0's crc beside v2.1's md5 and sha1.""" def test_the_platform_record_stays_whole_when_the_truth_accepts_it(self): - from exporter.baseline import NativeFile + from resolve.reconcile import NativeFile fe = NativeFile( name="syscard2.pce", destination="syscard2.pce", native_system="pce", @@ -2827,7 +2822,7 @@ class ARecordDescribesOneDump(unittest.TestCase): self.assertEqual(fe.record_hash("md5"), "3cdd6614" + "0" * 24) def test_a_field_only_the_truth_names_is_written_when_unambiguous(self): - from exporter.baseline import NativeFile + from resolve.reconcile import NativeFile one = NativeFile(name="a", destination="a", native_system="s", platform={"crc32": "11111111"}, diff --git a/tests/test_fileless_audit.py b/tests/test_fileless_audit.py index 53033a5b0..5d900a3b5 100644 --- a/tests/test_fileless_audit.py +++ b/tests/test_fileless_audit.py @@ -162,7 +162,7 @@ class TestCorpusIsAnswered(unittest.TestCase): def test_no_fileless_profile_is_left_unexplained(self): if not (ROOT / ".cache").is_dir(): self.skipTest("no upstream cache") - from safeparse import yaml_load + from model.safeparse import yaml_load fetch = fileless_audit.upstream.fetch_file read = [] diff --git a/tests/test_gap_settlement.py b/tests/test_gap_settlement.py index 529a14818..0df3f4e5e 100644 --- a/tests/test_gap_settlement.py +++ b/tests/test_gap_settlement.py @@ -13,7 +13,7 @@ import unittest from pathlib import Path from cross_reference import cross_reference -from validation import case_folded_slots, declaration_settles +from resolve.validation import case_folded_slots, declaration_settles REPO_ROOT = Path(__file__).resolve().parents[1] diff --git a/tests/test_hashing.py b/tests/test_hashing.py index ebbcf8be6..c33ae09e8 100644 --- a/tests/test_hashing.py +++ b/tests/test_hashing.py @@ -10,7 +10,7 @@ import unittest from pathlib import Path from unittest import mock -import hashing +from core import hashing REPO_ROOT = Path(__file__).resolve().parents[1] diff --git a/tests/test_install_experience.py b/tests/test_install_experience.py index e71d72537..ebe4d69c6 100644 --- a/tests/test_install_experience.py +++ b/tests/test_install_experience.py @@ -242,7 +242,7 @@ class ManifestHashesMatchTheScan(unittest.TestCase): value back: one read of the file, then a refusal a second read would have avoided.""" import generate_pack - import hashing + from core import hashing real_compute = hashing._compute_hashes reads: list[str] = [] diff --git a/tests/test_install_expert.py b/tests/test_install_expert.py index 1b7e21b75..cfe82452f 100644 --- a/tests/test_install_expert.py +++ b/tests/test_install_expert.py @@ -267,7 +267,7 @@ class TheSlotRuleIsTheBuilders(unittest.TestCase): import random import manifestselect - import slot as slot_mod + from resolve import slot as slot_mod rng = random.Random(7) for _round in range(400): @@ -302,7 +302,7 @@ class TheSlotRuleIsTheBuilders(unittest.TestCase): import random import manifestselect - import slot as slot_mod + from resolve import slot as slot_mod rng = random.Random(11) for _round in range(400): diff --git a/tests/test_install_selection.py b/tests/test_install_selection.py index 098b5e636..d16eb1527 100644 --- a/tests/test_install_selection.py +++ b/tests/test_install_selection.py @@ -1073,7 +1073,7 @@ class AHeldFileTheInstallerCannotFetch(unittest.TestCase): # no copy, and this offline run fetches none. Path(".gitignore").write_text("bios/Sys/jp.bin\n") registered = mock.patch( - "largefiles.load_registered_paths", return_value=["bios/Sys/jp.bin"] + "model.largefiles.load_registered_paths", return_value=["bios/Sys/jp.bin"] ) registered.start() self.addCleanup(registered.stop) diff --git a/tests/test_large_file_cache.py b/tests/test_large_file_cache.py index 2b4b7d925..ab1943e7c 100644 --- a/tests/test_large_file_cache.py +++ b/tests/test_large_file_cache.py @@ -23,7 +23,7 @@ from pathlib import Path from unittest import mock import common -import largefiles +from model import largefiles import check_release_assets REPO_ROOT = Path(__file__).resolve().parent.parent diff --git a/tests/test_launcher_evidence.py b/tests/test_launcher_evidence.py index 4d17179d4..33a726c44 100644 --- a/tests/test_launcher_evidence.py +++ b/tests/test_launcher_evidence.py @@ -15,7 +15,7 @@ from pathlib import Path import yaml from common import load_platform_config -from launchers import ( +from resolve.launchers import ( bound_launchers, config_evidence, config_target, diff --git a/tests/test_launcher_layer.py b/tests/test_launcher_layer.py index 09d2d5d3e..60e7a78b8 100644 --- a/tests/test_launcher_layer.py +++ b/tests/test_launcher_layer.py @@ -21,7 +21,7 @@ import zipfile import yaml from common import _emulator_profiles_cache, load_emulator_profiles, load_platform_config -from launchers import LauncherLayer, launcher_places, suffixed_stem +from resolve.launchers import LauncherLayer, launcher_places, suffixed_stem from verify import find_undeclared_files, verify_platform CONTENT = { @@ -392,7 +392,7 @@ class LauncherLayerTest(unittest.TestCase): self.assertEqual(launcher_places(self.config)[2].paths, ("sub/sub/fix.bin",)) def test_every_extractor_spelling_of_the_bios_folder_is_known(self) -> None: - import launchers + from resolve import launchers from scraper import emudeck_launchers, retrodeck_launchers, retropie_launchers for token in (emudeck_launchers.BIOS, retrodeck_launchers.BIOS, @@ -428,7 +428,7 @@ class LauncherLayerTest(unittest.TestCase): scph1002a.bin as packed while the PAL slot was filled by the launcher's scph5502.bin, which verify and the builder both knew.""" from cross_reference import cross_reference, declared_names, load_platform_files - from launchers import declared_destinations + from resolve.launchers import declared_destinations selected = ["launchertest"] declared, data_dirs = load_platform_files(self.platforms_dir, selected) diff --git a/tests/test_launcher_paths.py b/tests/test_launcher_paths.py index d19388253..806efe876 100644 --- a/tests/test_launcher_paths.py +++ b/tests/test_launcher_paths.py @@ -16,7 +16,7 @@ import textwrap import unittest from pathlib import Path -from launchers import handed_directories, standalone_bindings +from resolve.launchers import handed_directories, standalone_bindings from scraper import retrobat_launchers as rl from scraper.batocera_launchers import ( GENERATORS, diff --git a/tests/test_launcher_placement.py b/tests/test_launcher_placement.py index 3512fb631..0f3b18321 100644 --- a/tests/test_launcher_placement.py +++ b/tests/test_launcher_placement.py @@ -679,7 +679,7 @@ class ASettingSetsTheBiosFolder(unittest.TestCase): ) def test_the_ini_key_carries_its_section(self) -> None: - from launchers import ini_keys + from resolve.launchers import ini_keys self.assertEqual( ini_keys("PCSX2.ini [Folders] Bios = /storage/roms/bios/armsx2, [Filenames] BIOS"), @@ -725,7 +725,7 @@ class FlycastOnEmuELEC(unittest.TestCase): and root's home is /storage (busybox profile.d/98-busybox.conf:4).""" def test_the_home_directory_is_spelled_as_home(self) -> None: - from launchers import normalize_handle + from resolve.launchers import normalize_handle self.assertEqual( normalize_handle("/storage/.local/share/flycast", "/storage"), "~/.local/share/flycast" @@ -1347,7 +1347,7 @@ class MacBootDisksOnKnulli(unittest.TestCase): # mameGenerator.py and libretroMAMEConfig.py pass the boot disk as # -hard, the brief name of the LC III's one hard disk image # (harddriv.h:43, diimage.cpp:1131-1165, maclc3.cpp:266). - from launchers import bound_launchers + from resolve.launchers import bound_launchers config = load_platform_config("knulli", str(REPO_ROOT / "platforms")) profiles = load_emulator_profiles(str(REPO_ROOT / "emulators")) diff --git a/tests/test_libretro_layout.py b/tests/test_libretro_layout.py index 4bb8e8ef7..8f68abac1 100644 --- a/tests/test_libretro_layout.py +++ b/tests/test_libretro_layout.py @@ -16,11 +16,7 @@ import unittest from pathlib import Path from packpaths import _resolve_destination -from validation import ( - outside_gap_scope, - read_from_save_dir, - read_from_system_dir, -) +from resolve.validation import outside_gap_scope, read_from_save_dir, read_from_system_dir REPO_ROOT = Path(__file__).resolve().parents[1] diff --git a/tests/test_native_mode.py b/tests/test_native_mode.py index dd089059e..e6085841c 100644 --- a/tests/test_native_mode.py +++ b/tests/test_native_mode.py @@ -18,7 +18,7 @@ import json import unittest from pathlib import Path -import nativemode +from resolve import nativemode REPO_ROOT = Path(__file__).resolve().parent.parent diff --git a/tests/test_profile_checks.py b/tests/test_profile_checks.py index c71f2cc5b..d4c7fef4c 100644 --- a/tests/test_profile_checks.py +++ b/tests/test_profile_checks.py @@ -18,7 +18,7 @@ from pathlib import Path import yaml -from validation import _build_validation_index, check_file_validation +from resolve.validation import _build_validation_index, check_file_validation REPO_ROOT = Path(__file__).resolve().parents[1] @@ -368,7 +368,7 @@ class FbAlpha2012HiscoreFromSaveDir(unittest.TestCase): bios/hiscore.dat slot that MAME cores read on RetroDECK and RetroBat.""" def test_hiscore_is_not_a_system_file(self): - from validation import read_from_system_dir + from resolve.validation import read_from_system_dir for emulator in ("fbalpha2012", "fbalpha2012_cps3"): with self.subTest(emulator=emulator): @@ -427,7 +427,7 @@ class BizHawkFindsFirmwareByHash(unittest.TestCase): writes, and the export added 59 of them to RetroBat's native file.""" def test_entries_are_labels_named_by_the_firmware_database(self): - from validation import opens_by_name + from resolve.validation import opens_by_name profile = _profile("bizhawk") named = [f["name"] for f in profile["files"] if opens_by_name(f, profile, True)] @@ -444,7 +444,7 @@ class AmiberryNamesComeFromItsCode(unittest.TestCase): writes, and the code has its own AROS (':AROS', src/memory.cpp:2156).""" def test_scan_label_and_no_launcher_names(self): - from validation import opens_by_name + from resolve.validation import opens_by_name profile = _profile("amiberry") entry = next(f for f in profile["files"] if f["name"] == "amiga-os-310.rom") @@ -462,7 +462,7 @@ class WinUaeNamesComeFromItsCode(unittest.TestCase): Uae.Generator.cs searches, and kick.rom was missing.""" def test_kick_rom_is_read_by_name_and_kickstarts_are_labels(self): - from validation import opens_by_name, read_from_system_dir + from resolve.validation import opens_by_name, read_from_system_dir profile = _profile("winuae") kick = next(f for f in profile["files"] if f["name"] == "kick.rom") diff --git a/tests/test_region.py b/tests/test_region.py index bd584dc78..b2919f676 100644 --- a/tests/test_region.py +++ b/tests/test_region.py @@ -263,7 +263,7 @@ class TestStandaloneLayoutIsIndexed(unittest.TestCase): pack nor in --emulator dolphin --standalone.""" def test_the_standalone_path_carries_its_own_regions(self): - import slot + from resolve import slot profiles = {"dolphin": {"files": [ {"name": "IPL.bin", "path": "dolphin-emu/Sys/GC/USA/IPL.bin", diff --git a/tests/test_region_held.py b/tests/test_region_held.py index 7243e523a..e9bf91692 100644 --- a/tests/test_region_held.py +++ b/tests/test_region_held.py @@ -91,7 +91,7 @@ class ADataDirectoryCopyIsHeld(unittest.TestCase): def test_emulator_entry_from_a_data_tree(self): from packextras import _emulator_ships - from validation import _build_validation_index + from resolve.validation import _build_validation_index profile = self.profiles["dolphin-mmjr2"] entry = next( diff --git a/tests/test_region_platform_index.py b/tests/test_region_platform_index.py index 4a4e9455a..51b7cb5b8 100644 --- a/tests/test_region_platform_index.py +++ b/tests/test_region_platform_index.py @@ -56,7 +56,7 @@ class OnlyThePlatformsCoresRankASlot(unittest.TestCase): } def test_a_foreign_rank_orders_nothing(self): - import slot as slot_mod + from resolve import slot as slot_mod config = {"cores": ["beetle_psx"], "systems": {"sony-playstation": {"files": []}}} index = slot_mod.platform_slot_index(config, self.PROFILES) diff --git a/tests/test_romfolders_card.py b/tests/test_romfolders_card.py index 3fb4e7e0c..f3a817f92 100644 --- a/tests/test_romfolders_card.py +++ b/tests/test_romfolders_card.py @@ -14,7 +14,7 @@ import unittest from pathlib import Path from romfolders import split_refs -from safeparse import yaml_load +from model.safeparse import yaml_load from scraper.romfolders import SourceError, load_sources, scrape_setup from scraper.romfolders.__main__ import dump_setup from scraper.romfolders.card import ( diff --git a/tests/test_romfolders_es.py b/tests/test_romfolders_es.py index 1ad70b6b2..3938d4b98 100644 --- a/tests/test_romfolders_es.py +++ b/tests/test_romfolders_es.py @@ -353,7 +353,7 @@ class CommittedSetups(unittest.TestCase): from jsonschema import Draft202012Validator except ImportError: self.skipTest("jsonschema not installed") - from safeparse import yaml_load + from model.safeparse import yaml_load schema = json.loads((ROOT / "schemas" / "romfolders.schema.json").read_text()) validator = Draft202012Validator(schema) for setup in ES_SETUPS: @@ -363,7 +363,7 @@ class CommittedSetups(unittest.TestCase): self.assertEqual(errors, []) def test_every_source_ref_names_a_declared_source(self) -> None: - from safeparse import yaml_load + from model.safeparse import yaml_load for setup in ES_SETUPS: with self.subTest(setup=setup): doc = yaml_load(self.written(setup).read_text(encoding="utf-8")) @@ -381,14 +381,14 @@ class CommittedSetups(unittest.TestCase): self.assertIn(key, doc["sources"]) def test_committed_file_is_its_own_dump(self) -> None: - from safeparse import yaml_load + from model.safeparse import yaml_load for setup in ES_SETUPS: with self.subTest(setup=setup): text = self.written(setup).read_text(encoding="utf-8") self.assertEqual(dump_setup(yaml_load(text)), text) def test_elec_family_skips_its_bios_folder(self) -> None: - from safeparse import yaml_load + from model.safeparse import yaml_load for setup in ("rocknix", "jelos", "kolos", "unofficialos", "archr", "amberelec", "chaos", "pan4elec", "emuelec", "arkos", "darkos"): doc = yaml_load(self.paths[setup].read_text(encoding="utf-8")) diff --git a/tests/test_romm_hash_rule.py b/tests/test_romm_hash_rule.py index 891ba26ef..af535f8c0 100644 --- a/tests/test_romm_hash_rule.py +++ b/tests/test_romm_hash_rule.py @@ -17,8 +17,8 @@ import unittest import zlib from pathlib import Path -from nativemode import HASH_RULES, SIZE_AND_ANY_HASH -from validation import baseline_verdict, frontend_digest_matches +from resolve.nativemode import HASH_RULES, SIZE_AND_ANY_HASH +from resolve.validation import baseline_verdict, frontend_digest_matches from verify import Status, verify_entry_md5 REPO_ROOT = Path(__file__).resolve().parents[1] diff --git a/tests/test_save_root.py b/tests/test_save_root.py index 7219e3c36..4e45c17dc 100644 --- a/tests/test_save_root.py +++ b/tests/test_save_root.py @@ -38,7 +38,7 @@ from packpaths import ( save_destination, save_layout, ) -from validation import ( +from resolve.validation import ( entry_root, outside_gap_scope, read_from_save_dir, diff --git a/tests/test_shared_groups.py b/tests/test_shared_groups.py index ba90a91f0..f272e9eff 100644 --- a/tests/test_shared_groups.py +++ b/tests/test_shared_groups.py @@ -15,7 +15,7 @@ import unittest from pathlib import Path from common import load_emulator_profiles -from safeparse import yaml_load +from model.safeparse import yaml_load REPO_ROOT = Path(__file__).resolve().parents[1] diff --git a/tests/test_shipped_content.py b/tests/test_shipped_content.py index e105d2ebf..4c4f57237 100644 --- a/tests/test_shipped_content.py +++ b/tests/test_shipped_content.py @@ -27,7 +27,7 @@ import zipfile from pathlib import Path import common -from nativemode import reads_file_contents +from resolve.nativemode import reads_file_contents ROOT = Path(__file__).resolve().parent.parent diff --git a/tests/test_site_exports.py b/tests/test_site_exports.py index 352bf7000..5ff9cc1f3 100644 --- a/tests/test_site_exports.py +++ b/tests/test_site_exports.py @@ -680,7 +680,7 @@ class AHashFindsEveryPageThatNamesIt(unittest.TestCase): import generate_site from common import load_platform_config from cross_reference import FileConsumers - from ziptools import build_zip_contents_index + from core.ziptools import build_zip_contents_index root = Path(__file__).resolve().parents[1] db = _json.loads((root / "database.json").read_text(encoding="utf-8")) diff --git a/tests/test_site_reference.py b/tests/test_site_reference.py index 8cfdab7c5..73faca5ab 100644 --- a/tests/test_site_reference.py +++ b/tests/test_site_reference.py @@ -60,8 +60,8 @@ from common import ( load_platform_config, list_release_pack_platforms, ) -from exporter.baseline import HASH_FIELDS, _hash_values -from exporter.candidates import EntryCategories +from resolve.reconcile import HASH_FIELDS, _hash_values +from resolve.categories import EntryCategories from sitesources import launcher_ref_markdown, list_source import check_platform_folder import sitesources diff --git a/tests/test_site_system_sections.py b/tests/test_site_system_sections.py index 90c9879b0..acb6e623e 100644 --- a/tests/test_site_system_sections.py +++ b/tests/test_site_system_sections.py @@ -74,7 +74,7 @@ def _archives_held(fe: dict, db: dict) -> set[str]: holds: by its name, kept when it holds one CRC32 its ``contents:`` lists. MAME hashes the members, never the archive, so the entry has no hash of its own and a name match is the only way to it.""" - from ziptools import zip_member_crcs + from core.ziptools import zip_member_crcs crcs = {str(m["crc32"]).lower() for m in fe.get("contents") or [] if isinstance(m, dict) and m.get("crc32")} diff --git a/tests/test_site_wanted.py b/tests/test_site_wanted.py index ba575c7d9..a5aea0577 100644 --- a/tests/test_site_wanted.py +++ b/tests/test_site_wanted.py @@ -654,7 +654,7 @@ class ThePublishedList(unittest.TestCase): """Each emulator a row names declares that file as firmware it does not install itself: pak0.pk3, game data for every profile, is gone.""" from common import load_emulator_profiles - from validation import installed_with_emulator + from resolve.validation import installed_with_emulator profiles = load_emulator_profiles(str(REPO_ROOT / "emulators")) self.assertNotIn("pak0.pk3", [e["n"] for e in self.data["entries"]]) diff --git a/tests/test_slot.py b/tests/test_slot.py index 904a15308..8b022e14a 100644 --- a/tests/test_slot.py +++ b/tests/test_slot.py @@ -7,7 +7,7 @@ import tests import os import unittest -import slot +from resolve import slot def _pairs(*names: str) -> list[tuple[str, str]]: @@ -261,7 +261,7 @@ class AnUnrankedDeclarationIsADisagreement(unittest.TestCase): bios_CD_U.bin by name and ranks nothing.""" def test_the_file_genesis_plus_gx_opens_is_kept(self): - from slot import build_slot_index, resolve_slot_drops + from resolve.slot import build_slot_index, resolve_slot_drops profiles = { "picodrive": {"files": [ @@ -280,7 +280,7 @@ class AnUnrankedDeclarationIsADisagreement(unittest.TestCase): self.assertEqual(undecidable, ["sega-mega-cd"]) def test_one_core_ranking_alone_still_decides(self): - from slot import build_slot_index, resolve_slot_drops + from resolve.slot import build_slot_index, resolve_slot_drops index = build_slot_index({"picodrive": {"files": [ {"name": "a.bin", "priority": 1}, {"name": "b.bin", "priority": 2}, @@ -297,7 +297,7 @@ class AnAbsentRankOneDisplacesNothing(unittest.TestCase): dropped the rank-2 and rank-3 files it holds, leaving the slot empty.""" def test_the_best_held_file_wins(self): - from slot import build_slot_index, resolve_slot_drops + from resolve.slot import build_slot_index, resolve_slot_drops index = build_slot_index({"picodrive": {"files": [ {"name": "us_scd2_9306.bin", "priority": 1}, diff --git a/tests/test_split_pack.py b/tests/test_split_pack.py index 24df4a7c4..3df9cc69a 100644 --- a/tests/test_split_pack.py +++ b/tests/test_split_pack.py @@ -28,7 +28,7 @@ import zipfile from pathlib import Path import generate_pack as builder -from artifacts import artifact_lock +from core.artifacts import artifact_lock import split_pack REPO_ROOT = Path(__file__).resolve().parent.parent diff --git a/tests/test_standalone_links.py b/tests/test_standalone_links.py index db0f10a41..43c054cc2 100644 --- a/tests/test_standalone_links.py +++ b/tests/test_standalone_links.py @@ -28,7 +28,7 @@ from common import ( standalone_set, system_file_index, ) -from launchers import ( +from resolve.launchers import ( SEARCHED_FILES, bound_path, handed_directories, diff --git a/tests/test_tool_messages.py b/tests/test_tool_messages.py index c2e5d8eff..b68fd2ab1 100644 --- a/tests/test_tool_messages.py +++ b/tests/test_tool_messages.py @@ -18,7 +18,7 @@ from unittest import mock import common import diff_truth import pipeline -import truth +from resolve import truth import verify REPO_ROOT = Path(__file__).resolve().parents[1] diff --git a/tests/test_truth_data_dir_readers.py b/tests/test_truth_data_dir_readers.py index 89f0dbbc1..b4cec1dd0 100644 --- a/tests/test_truth_data_dir_readers.py +++ b/tests/test_truth_data_dir_readers.py @@ -17,8 +17,8 @@ import tempfile import unittest from pathlib import Path -from exporter.baseline import checked_hashes -from truth import generate_platform_truth +from resolve.reconcile import checked_hashes +from resolve.truth import generate_platform_truth REPO_ROOT = Path(__file__).resolve().parent.parent diff --git a/tests/test_truth_diff.py b/tests/test_truth_diff.py index 7ff5008c8..a4e72e733 100644 --- a/tests/test_truth_diff.py +++ b/tests/test_truth_diff.py @@ -17,12 +17,8 @@ import sys import tempfile import unittest -from exporter.baseline import pair_entries -from truth import ( - _diff_system, - _merge_file_into_system, - generate_platform_truth, -) +from resolve.reconcile import pair_entries +from resolve.truth import _diff_system, _merge_file_into_system, generate_platform_truth def _entry(name: str, **hashes) -> dict: diff --git a/tests/test_truth_layout.py b/tests/test_truth_layout.py index abce37dfb..8ee917ae7 100644 --- a/tests/test_truth_layout.py +++ b/tests/test_truth_layout.py @@ -18,7 +18,7 @@ import sys import unittest from pathlib import Path -from truth import generate_platform_truth +from resolve.truth import generate_platform_truth REPO_ROOT = Path(__file__).resolve().parents[1] @@ -181,7 +181,7 @@ class EveryRevisionACoreAcceptsStays(unittest.TestCase): giving 1.07's sha1 and md5 is that revision, not a mismatch. dosbox checks the sha1 (validation), so its md5 describes one revision and contradicts nothing, the rule the export applies too.""" - from truth import _hash_mismatch + from resolve.truth import _hash_mismatch truth = {"name": "MT32_CONTROL.ROM", "md5": "c" * 32, "sha1": ["a" * 40, "b" * 40], "validation": ["sha1"]} @@ -205,8 +205,8 @@ class DiffAndExportShareOneMismatchRule(unittest.TestCase): ) def test_the_diff_names_what_the_export_corrects(self): - from exporter.baseline import build_native_model - from truth import diff_platform_truth + from resolve.reconcile import build_native_model + from resolve.truth import diff_platform_truth for t_hashes, p_hashes in self.CASES: with self.subTest(truth=t_hashes, platform=p_hashes): @@ -326,7 +326,7 @@ class ASizeOutsideARangeIsAnotherFile(unittest.TestCase): def test_two_cores_do_not_merge_across_a_declared_range(self): """bk's 24 KB BASIC10.ROM and oricutron's basic10.rom (max_size 16384) merged into one entry, which took the Oric md5.""" - from truth import _merge_file_into_system + from resolve.truth import _merge_file_into_system system: dict = {} _merge_file_into_system(system, {"name": "BASIC10.ROM", "size": 24576, @@ -452,7 +452,7 @@ class TheModelIsAFunctionOfItsInputs(unittest.TestCase): SCRIPT = ( "import json, sys\n" "sys.path.insert(0, sys.argv[1])\n" - "from truth import generate_platform_truth\n" + "from resolve.truth import generate_platform_truth\n" "names = [f'core{i:02d}' for i in range(16)]\n" "profiles = {n: {'emulator': n, 'type': 'libretro',\n" " 'systems': [f'maker-system-{n}'], 'files': []} for n in names}\n" diff --git a/tests/test_validate_pr.py b/tests/test_validate_pr.py index 30c2fd39f..8c67e4602 100644 --- a/tests/test_validate_pr.py +++ b/tests/test_validate_pr.py @@ -540,7 +540,7 @@ class ThePlatformsOwnCheckDecides(_Fixture): self.assertNotIn(".variants/", markdown) def test_a_member_digest(self): - from hashing import md5_composite + from core.hashing import md5_composite path = self._zip() known = self._platforms( diff --git a/tests/test_validated_choice.py b/tests/test_validated_choice.py index 3dc48ade9..4ea5049e5 100644 --- a/tests/test_validated_choice.py +++ b/tests/test_validated_choice.py @@ -16,11 +16,7 @@ import tempfile import unittest from pathlib import Path -from validation import ( - _build_validation_index, - destination_owners, - validated_choice, -) +from resolve.validation import _build_validation_index, destination_owners, validated_choice REPO_ROOT = Path(__file__).resolve().parent.parent @@ -159,7 +155,7 @@ class ManifestsServeWhatTheCoreAccepts(unittest.TestCase): from common import load_emulator_profiles, load_platform_config from generate_pack import _platform_cores - from validation import check_file_validation + from resolve.validation import check_file_validation manifest_path = REPO_ROOT / "install" / "retroarch.json" if not (REPO_ROOT / "database.json").is_file() or not manifest_path.is_file(): @@ -195,7 +191,7 @@ class EachReaderJudgesWithItsOwnRules(unittest.TestCase): Wii U otp.bin, and the variant search gave Cemu the 3DS file.""" def test_rules_of_another_emulator_do_not_judge(self): - from validation import check_file_validation + from resolve.validation import check_file_validation index = _build_validation_index({ "azahar": {"files": [{"name": "otp.bin", "path": "sysdata/otp.bin", @@ -210,7 +206,7 @@ class EachReaderJudgesWithItsOwnRules(unittest.TestCase): self.assertIsNotNone(check_file_validation(str(wiiu), "otp.bin", index, tmp, {"azahar"})) def test_one_of_an_emulators_entries_is_enough(self): - from validation import check_file_validation + from resolve.validation import check_file_validation index = _build_validation_index({"raze": {"files": [ {"name": "SW.GRP", "size": 100, "validation": ["size"]}, @@ -233,7 +229,7 @@ class DolphinForksJudgeTheirOwnDspTable(unittest.TestCase): def test_each_fork_accepts_its_own_free_rom(self): from common import load_emulator_profiles - from validation import check_file_validation + from resolve.validation import check_file_validation if not self.FREE_V04.is_file() or not self.FREE_V031.is_file(): self.skipTest("free DSP ROMs not present") @@ -290,7 +286,7 @@ class AWarningRejectsNothing(unittest.TestCase): self.assertEqual((chosen, disagreement), (str(good), None)) def test_the_merged_view_rejects_nothing_for_it(self): - from validation import check_file_validation + from resolve.validation import check_file_validation with tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp") as tmp: short, _good, _db, index = self._setup(tmp, held_good=False) @@ -305,7 +301,7 @@ class AlternativesAreLookedUpBySlot(unittest.TestCase): from unittest import mock import packextras - import validation + from resolve import validation files = [{"name": "DUKE3D.GRP", "size": n} for n in (1, 2)] + [ {"name": "a.bin", "path": "dir/a.bin"}, {"name": "a.bin"}, "not an entry", @@ -345,7 +341,7 @@ class AVersionTakenWithoutACheck(unittest.TestCase): return str(path) def test_the_unchecked_version_accepts_the_copy(self): - from validation import check_file_validation + from resolve.validation import check_file_validation index = _build_validation_index({"raze": self.RAZE}) with tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp") as tmp: @@ -363,7 +359,7 @@ class AVersionTakenWithoutACheck(unittest.TestCase): )) def test_a_refusal_names_every_accepted_size(self): - from validation import check_file_validation + from resolve.validation import check_file_validation checked = {"files": self.RAZE["files"][:2]} index = _build_validation_index({"raze": checked}) diff --git a/tests/test_validation_scope.py b/tests/test_validation_scope.py index d74d8b8bc..b4cf4a84f 100644 --- a/tests/test_validation_scope.py +++ b/tests/test_validation_scope.py @@ -59,7 +59,7 @@ class ContentFoundLabelsTakeTheirRegionSlot(unittest.TestCase): import hashlib import tempfile - from validation import _build_validation_index, check_file_validation + from resolve.validation import _build_validation_index, check_file_validation with tempfile.TemporaryDirectory() as tmp: path = Path(tmp) / "scph1001.bin" @@ -96,7 +96,7 @@ class GearcolecoWarnsOnAnUnknownRevision(unittest.TestCase): import yaml - from validation import _build_validation_index, check_file_validation + from resolve.validation import _build_validation_index, check_file_validation profile = yaml.safe_load( (REPO_ROOT / "emulators" / "gearcoleco.yml").read_text(encoding="utf-8") diff --git a/tests/test_variant_choice.py b/tests/test_variant_choice.py index f171e75b1..ad5ccb280 100644 --- a/tests/test_variant_choice.py +++ b/tests/test_variant_choice.py @@ -20,7 +20,7 @@ import tempfile import unittest from pathlib import Path -from validation import find_validated_variant +from resolve.validation import find_validated_variant REPO_ROOT = Path(__file__).resolve().parents[1] @@ -50,7 +50,7 @@ class FindValidatedVariant(unittest.TestCase): "by_name": {"rom.bin": [s for s, e in self.files.items() if e["name"] == "rom.bin"]}, "by_md5": {e["md5"]: s for s, e in self.files.items()}, }} - from validation import _build_validation_index + from resolve.validation import _build_validation_index self.by_hash = _build_validation_index({"emu": {"files": [ {"name": "rom.bin", "validation": ["size", "sha1"], "size": 16, @@ -94,7 +94,7 @@ _SEEDED = """ import hashlib, sys, tempfile from pathlib import Path sys.path.insert(0, sys.argv[1]) -from validation import _build_validation_index, find_validated_variant +from resolve.validation import _build_validation_index, find_validated_variant root = Path(sys.argv[2]) paths = [root / f"ctrl_{i}.rom" for i in range(8)] files = {} diff --git a/tests/test_verify_release_asset.py b/tests/test_verify_release_asset.py index 10d06d733..10dcc6282 100644 --- a/tests/test_verify_release_asset.py +++ b/tests/test_verify_release_asset.py @@ -66,7 +66,7 @@ class ReleaseAssetNotCached(unittest.TestCase): common._platform_config_cache.clear() common._emulator_profiles_cache.clear() patches = ( - mock.patch("largefiles.load_registered_paths", return_value=REGISTERED), + mock.patch("model.largefiles.load_registered_paths", return_value=REGISTERED), mock.patch.dict(os.environ, {"RETROBIOS_OFFLINE": ""}), ) for patch in patches: diff --git a/tests/test_zipped_member.py b/tests/test_zipped_member.py index 5028dd3f3..24429e7ae 100644 --- a/tests/test_zipped_member.py +++ b/tests/test_zipped_member.py @@ -65,7 +65,7 @@ class TheMemberIndexIsCachedByContent(unittest.TestCase): def test_a_second_process_reads_the_cache(self): from unittest import mock - import ziptools + from core import ziptools with tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp") as tmp: archive = Path(tmp) / "set.zip" diff --git a/wiki/adding-a-platform.md b/wiki/adding-a-platform.md index e1b6f5141..1234ed906 100644 --- a/wiki/adding-a-platform.md +++ b/wiki/adding-a-platform.md @@ -512,7 +512,7 @@ that names the BIOS directory must match a known construct, else the scrape stops with `LauncherPatternMissing`. `verify.py` and the pack builder read the records through one function, -`LauncherLayer.settle()` in `scripts/launchers.py`, applied inside the +`LauncherLayer.settle()` in `scripts/resolve/launchers.py`, applied inside the cross-reference both of them consume. A `names_searched` list is one place: the names are tried in order and one held file fills it, so a core file the launcher would never open once another name of the list is there is not diff --git a/wiki/release-process.md b/wiki/release-process.md index 5ec622fb6..774c935de 100644 --- a/wiki/release-process.md +++ b/wiki/release-process.md @@ -192,7 +192,7 @@ shares is published under that file name. When two paths share one, each is published under its location below `bios/`, segments joined by `--` and any character outside `A-Za-z0-9._-` replaced by `_` (`Id_Software--Wolfenstein_Enemy_Territory--etmain--pak0.pk3`). -`asset_names()` in `scripts/largefiles.py` is the only place that rule lives: +`asset_names()` in `scripts/model/largefiles.py` is the only place that rule lives: the manifests, the fetcher and `check_release_assets.py` all read it. **Upload.** To add or update a large file: diff --git a/wiki/verification-modes.md b/wiki/verification-modes.md index 6ebf809b3..66da75d3f 100644 --- a/wiki/verification-modes.md +++ b/wiki/verification-modes.md @@ -91,7 +91,7 @@ shorter than 32 characters matches no file there. The Batocera scraper completes a value when exactly one MD5 in `database.json` starts with it (`_resolve_truncated_md5` in `scripts/scraper/batocera_scraper.py`) and keeps it as written otherwise. `resolve_local_file` and `--from-md5` read a value still shorter -than 32 characters by the same rule (`cut_md5_owner` in `scripts/hashing.py`), and the +than 32 characters by the same rule (`cut_md5_owner` in `scripts/core/hashing.py`), and the resolver keeps the file only when its name is one the entry names. Every verdict compares whole digests, as Batocera does: a cut value never verifies a file. @@ -103,12 +103,12 @@ Recalbox 10.1.1): one MD5 over the contents of every member, read in filename order. The members' own MD5s are not involved, and neither is the MD5 of the ZIP file itself: `Bios::Scan` takes the composite for every `.zip` ([`es-app/src/bios/Bios.cpp:86-91`](https://gitlab.com/recalbox/recalbox/-/blob/10.1.1/projects/frontend/es-app/src/bios/Bios.cpp#L86-91)). `verify.py` computes the same value with -`md5_composite()` (`scripts/hashing.py`). +`md5_composite()` (`scripts/core/hashing.py`). The registry gives Recalbox `zip_digest: composite`. For a platform so marked, a `.zip` entry is checked against its composite alone, by the resolver (`resolve_local_file`) and by the pack check (`digest_verdict` in -`scripts/validation.py`). On other platforms the ZIP file's direct MD5 is tried first +`scripts/resolve/validation.py`). On other platforms the ZIP file's direct MD5 is tried first and the composite after it. ### Multi-hash (Recalbox) @@ -277,7 +277,7 @@ firmware). `verify.py` reports these as informational but cannot verify them wit the keys. Size checks still apply if combined with crypto. **Content tests** (`CONTENT_CHECKS` in `common.py`): `romdir` walks a PS2 ROM -directory the way the profile's fork reads it (`scripts/romdir.py`), and +directory the way the profile's fork reads it (`scripts/core/romdir.py`), and `masked_sha1` hashes a file with a byte range cleared. `content_fits()` runs them, and the name steps of the resolver, the folder scans of the pack and manifest, the emulator expansion and `verify.py` all call it, so they accept and refuse the @@ -448,7 +448,7 @@ pack verification apply the same rule. ### Variant search -`validated_choice()` (`scripts/validation.py`) decides the file a platform +`validated_choice()` (`scripts/resolve/validation.py`) decides the file a platform destination ships when the emulators reading that destination check it. The pack, verify and the install manifest all read it, so they name the same file.