mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-24 10:37:54 -06:00
refactor: leave the commands their own code
This commit is contained in:
1 parent
1f8e106974
commit
27330be60a
17 files changed
+47
-72
No files matched your search
@@ -17,7 +17,6 @@ import json
|
||||
import os
|
||||
import sys
|
||||
from dataclasses import dataclass
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
sys.path.insert(0, os.path.dirname(__file__))
|
||||
from model.cliargs import platform_arg, list_emulator_profiles, require_platform
|
||||
@@ -34,8 +33,6 @@ from resolve.launchers import (
|
||||
launcher_unproven,
|
||||
)
|
||||
|
||||
if TYPE_CHECKING:
|
||||
pass
|
||||
from packs.crossref import (
|
||||
DEFAULT_PLATFORMS_DIR,
|
||||
_build_supplemental_index,
|
||||
|
||||
@@ -27,7 +27,6 @@ import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
from dataclasses import dataclass
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
sys.path.insert(0, os.path.dirname(__file__))
|
||||
from resolve.cores import resolve_platform_cores as _platform_cores
|
||||
@@ -76,17 +75,7 @@ from resolve import packfiles as packresolve
|
||||
from packs.datadirs import hold_data_dirs
|
||||
from model import region
|
||||
|
||||
from packs.extras import (
|
||||
_emulator_region_group as _emulator_region_group,
|
||||
)
|
||||
from packs.integrity import (
|
||||
_check_member_hash as _check_member_hash,
|
||||
_hash_matches as _hash_matches,
|
||||
_intentional_hash_exclusion as _intentional_hash_exclusion,
|
||||
verify_pack_against_platform,
|
||||
)
|
||||
# _OFFLINE is deliberately not re-exported: importing a value copies it, so a
|
||||
# facade name would keep saying False after set_offline() changed the flag.
|
||||
from packs.integrity import verify_pack_against_platform
|
||||
from resolve.packfiles import (
|
||||
ACCEPTED_HASHES,
|
||||
parse_hash_input,
|
||||
@@ -94,8 +83,6 @@ from resolve.packfiles import (
|
||||
lookup_hashes,
|
||||
)
|
||||
|
||||
if TYPE_CHECKING:
|
||||
pass
|
||||
from packs.archive import DamagedArchiveError
|
||||
from packs.platformpack import generate_split_packs
|
||||
from packs.datatrees import _MISSING_DATA_DIRS
|
||||
@@ -127,9 +114,6 @@ DEFAULT_OUTPUT_DIR = "dist"
|
||||
DEFAULT_BIOS_DIR = "bios"
|
||||
|
||||
|
||||
# Emulator/system mode pack generation
|
||||
|
||||
|
||||
def _json_artifact_kind(path: Path) -> str | None:
|
||||
""""manifest" for an install manifest, "targets" for a per-target core
|
||||
list, None for anything else. The two share their file names: install.py
|
||||
@@ -1497,9 +1481,6 @@ def _main(held: contextlib.ExitStack) -> None:
|
||||
_run_platform_mode(args, parser, held, db, zip_contents)
|
||||
|
||||
|
||||
# Manifest generation (JSON inventory for install.py)
|
||||
|
||||
|
||||
def _write_standalone_layouts(output_dir: str, platform: str, layouts: dict) -> str:
|
||||
"""install/standalone/<platform>.json, what --standalone reads beside the
|
||||
list. Its [dest, sha1] items take their download from that list."""
|
||||
@@ -1511,9 +1492,6 @@ def _write_standalone_layouts(output_dir: str, platform: str, layouts: dict) ->
|
||||
return path
|
||||
|
||||
|
||||
# Post-generation pack verification + manifest + SHA256SUMS
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
from core.cli import run_cli
|
||||
|
||||
|
||||
@@ -47,6 +47,9 @@ if TYPE_CHECKING:
|
||||
from typing_extensions import Unpack
|
||||
|
||||
|
||||
# Platform verification
|
||||
|
||||
|
||||
_UNPLACED_REASONS = {
|
||||
"outside_bios_folder": "read in a folder the platform keeps outside the BIOS tree",
|
||||
"no_roms_directory": "read below a roms folder the platform's registry does not name",
|
||||
|
||||
@@ -47,6 +47,9 @@ from resolve.validation import (
|
||||
_REPO_PLATFORMS = str(REPO_ROOT / "platforms")
|
||||
|
||||
|
||||
# Emulator/system mode verification
|
||||
|
||||
|
||||
def _effective_validation_label(details: list[dict], validation_index: dict) -> str:
|
||||
"""Determine the bracket label for the report.
|
||||
|
||||
|
||||
@@ -61,6 +61,9 @@ if TYPE_CHECKING:
|
||||
_Outcome = tuple[list[dict], bool, "Callable[[], None] | None"]
|
||||
|
||||
|
||||
# Emulator/system mode pack generation
|
||||
|
||||
|
||||
class EmulatorPackOptions(TypedDict, total=False):
|
||||
"""The keyword options of generate_emulator_pack."""
|
||||
|
||||
|
||||
@@ -35,6 +35,9 @@ def _baseline_shortfall(excluded: int, absent: int) -> list[str]:
|
||||
return parts
|
||||
|
||||
|
||||
# Post-generation pack verification + manifest + SHA256SUMS
|
||||
|
||||
|
||||
def inject_manifest(zip_path: str, manifest: dict) -> None:
|
||||
"""Inject manifest.json into an existing ZIP pack.
|
||||
|
||||
|
||||
@@ -33,6 +33,9 @@ from resolve.validation import (
|
||||
)
|
||||
|
||||
|
||||
# Cross-reference: undeclared files used by cores
|
||||
|
||||
|
||||
def _build_expected(file_entry: dict, checks: list[str]) -> dict:
|
||||
"""Extract expected validation values from an emulator profile file entry."""
|
||||
expected: dict = {}
|
||||
|
||||
@@ -22,6 +22,9 @@ from resolve.packfiles import resolve_file
|
||||
from resolve.validation import validated_choice
|
||||
|
||||
|
||||
# Manifest generation (JSON inventory for install.py)
|
||||
|
||||
|
||||
@functools.cache
|
||||
def _registered(repo_root: str) -> frozenset[str]:
|
||||
"""The paths a repository's .gitignore registers as release assets, read
|
||||
|
||||
@@ -9,6 +9,9 @@ from resolve.categories import BIOS
|
||||
from resolve.nativemode import reads_file_contents
|
||||
|
||||
|
||||
# Output
|
||||
|
||||
|
||||
def _format_ground_truth_aggregate(ground_truth: list[dict]) -> str:
|
||||
"""Format ground truth as a single aggregated line.
|
||||
|
||||
|
||||
@@ -19,6 +19,9 @@ DEFAULT_BIOS_DIR = "bios"
|
||||
DEFAULT_EMULATORS_DIR = "emulators"
|
||||
|
||||
|
||||
# Status model: aligned with Batocera BiosStatus (batocera-systems:967-969)
|
||||
|
||||
|
||||
class Status:
|
||||
OK = "ok"
|
||||
UNTESTED = "untested" # file present, hash not confirmed: a warning, never --strict
|
||||
@@ -46,6 +49,9 @@ _SEVERITY_ORDER = {
|
||||
}
|
||||
|
||||
|
||||
# Verification functions
|
||||
|
||||
|
||||
def verify_entry_existence(
|
||||
file_entry: dict,
|
||||
local_path: str | None,
|
||||
@@ -218,6 +224,9 @@ def verify_entry_sha1(
|
||||
}
|
||||
|
||||
|
||||
# Severity mapping per platform
|
||||
|
||||
|
||||
def _emulator_severity(status: str, required: bool, hle_fallback: bool) -> str:
|
||||
"""Severity when the emulator's own code is the check.
|
||||
|
||||
|
||||
@@ -19,7 +19,6 @@ feeds the report this module prints.
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from model.cliargs import platform_arg, require_platform
|
||||
from model.database import load_database
|
||||
@@ -31,8 +30,6 @@ from model.targets import build_target_cores_cache
|
||||
from resolve.localfile import resolution_is_hash_exact
|
||||
from resolve.standalone import standalone_set as platform_standalone_set
|
||||
|
||||
if TYPE_CHECKING:
|
||||
pass
|
||||
from packs.slots import ADDRESSEE, Claim, Conflict, Decision, arbitrate, find_conflicts
|
||||
from resolve.collisions import Collision, find_collisions
|
||||
|
||||
|
||||
@@ -23,10 +23,7 @@ import os
|
||||
import shutil
|
||||
import sys
|
||||
from pathlib import Path
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
if TYPE_CHECKING:
|
||||
pass
|
||||
|
||||
sys.path.insert(0, os.path.dirname(__file__))
|
||||
from model.database import load_database
|
||||
|
||||
@@ -29,7 +29,6 @@ import json
|
||||
import os
|
||||
import sys
|
||||
from pathlib import Path
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
|
||||
sys.path.insert(0, os.path.dirname(__file__))
|
||||
@@ -65,9 +64,6 @@ from resolve.cores import (
|
||||
from model.safeparse import require_yaml
|
||||
|
||||
|
||||
if TYPE_CHECKING:
|
||||
|
||||
pass
|
||||
from packs.coverage import verify_platform
|
||||
from packs.emulatorcheck import verify_emulator, verify_system
|
||||
from packs.report import (
|
||||
@@ -86,27 +82,6 @@ DEFAULT_DB = "database.json"
|
||||
DEFAULT_PLATFORMS_DIR = "platforms"
|
||||
|
||||
|
||||
# Status model: aligned with Batocera BiosStatus (batocera-systems:967-969)
|
||||
|
||||
|
||||
# Verification functions
|
||||
|
||||
|
||||
# Severity mapping per platform
|
||||
|
||||
|
||||
# Cross-reference: undeclared files used by cores
|
||||
|
||||
|
||||
# Platform verification
|
||||
|
||||
|
||||
# Output
|
||||
|
||||
|
||||
# Emulator/system mode verification
|
||||
|
||||
|
||||
def _refuse_listing_narrowings(
|
||||
args: argparse.Namespace, parser: argparse.ArgumentParser
|
||||
) -> None:
|
||||
|
||||
@@ -34,7 +34,8 @@ from scripts import pipeline
|
||||
from scripts.resolve import regionaudit, regions
|
||||
from scripts.resolve.localfile import resolve_local_file
|
||||
from scripts.core.ziptools import safe_extract_zip
|
||||
from scripts.generate_pack import _emulator_region_group, verify_pack_against_platform
|
||||
from scripts.packs.extras import _emulator_region_group
|
||||
from scripts.packs.integrity import verify_pack_against_platform
|
||||
from scripts.packs.targets import generate_target_manifests
|
||||
|
||||
HAS_JSONSCHEMA = jsonschema is not None
|
||||
|
||||
+12
-12
@@ -2625,7 +2625,7 @@ class TestE2E(unittest.TestCase):
|
||||
|
||||
def test_138_parse_hash_input(self):
|
||||
"""parse_hash_input handles various formats."""
|
||||
from generate_pack import parse_hash_input
|
||||
from resolve.packfiles import parse_hash_input
|
||||
|
||||
# Plain MD5
|
||||
result = parse_hash_input("d8f1206299c48946e6ec5ef96d014eaa")
|
||||
@@ -2645,7 +2645,7 @@ class TestE2E(unittest.TestCase):
|
||||
|
||||
def test_139_parse_hash_file(self):
|
||||
"""parse_hash_file handles comments, empty lines, various formats."""
|
||||
from generate_pack import parse_hash_file
|
||||
from resolve.packfiles import parse_hash_file
|
||||
|
||||
with tempfile.NamedTemporaryFile(mode="w", suffix=".txt", delete=False) as f:
|
||||
f.write("# PS1 BIOS files\n")
|
||||
@@ -2666,7 +2666,7 @@ class TestE2E(unittest.TestCase):
|
||||
import contextlib
|
||||
import io
|
||||
|
||||
from generate_pack import lookup_hashes
|
||||
from resolve.packfiles import lookup_hashes
|
||||
|
||||
db = {
|
||||
"files": {
|
||||
@@ -2698,7 +2698,7 @@ class TestE2E(unittest.TestCase):
|
||||
import contextlib
|
||||
import io
|
||||
|
||||
from generate_pack import lookup_hashes
|
||||
from resolve.packfiles import lookup_hashes
|
||||
|
||||
db = {"files": {}, "indexes": {"by_md5": {}, "by_crc32": {}}}
|
||||
buf = io.StringIO()
|
||||
@@ -5325,7 +5325,7 @@ struct BurnDriver BurnDrvneogeo = {
|
||||
"""Pack verification reproduces the native md5 check per member."""
|
||||
import tempfile
|
||||
|
||||
from generate_pack import verify_pack_against_platform
|
||||
from packs.integrity import verify_pack_against_platform
|
||||
|
||||
with tempfile.TemporaryDirectory() as tmpdir:
|
||||
plat_dir, bios_root, out_dir, db, h, hl = self._make_hash_zip_fixture(
|
||||
@@ -5348,7 +5348,7 @@ struct BurnDriver BurnDrvneogeo = {
|
||||
"""Pack verification passes when member bytes match declared md5."""
|
||||
import tempfile
|
||||
|
||||
from generate_pack import verify_pack_against_platform
|
||||
from packs.integrity import verify_pack_against_platform
|
||||
|
||||
with tempfile.TemporaryDirectory() as tmpdir:
|
||||
plat_dir, bios_root, out_dir, db, h, hl = self._make_hash_zip_fixture(
|
||||
@@ -5370,7 +5370,7 @@ struct BurnDriver BurnDrvneogeo = {
|
||||
import tempfile
|
||||
|
||||
from packs.platformpack import generate_pack
|
||||
from generate_pack import verify_pack_against_platform
|
||||
from packs.integrity import verify_pack_against_platform
|
||||
|
||||
profiles = {"eng": {"emulator": "Eng", "type": "game", "cores": ["eng"],
|
||||
"systems": ["arcade-sys"],
|
||||
@@ -5408,7 +5408,7 @@ struct BurnDriver BurnDrvneogeo = {
|
||||
|
||||
def test_214_hash_matches_truncated_and_multi(self):
|
||||
"""Declared-hash compare handles truncation, case, multi-values."""
|
||||
from generate_pack import _hash_matches
|
||||
from packs.integrity import _hash_matches
|
||||
|
||||
full = "85254fbe320ca82a768ec2c26bb08def"
|
||||
self.assertTrue(_hash_matches(full, full))
|
||||
@@ -5630,7 +5630,7 @@ struct BurnDriver BurnDrvneogeo = {
|
||||
import hashlib as hl
|
||||
import tempfile
|
||||
|
||||
from generate_pack import _check_member_hash
|
||||
from packs.integrity import _check_member_hash
|
||||
|
||||
rom = b"inner rom bytes"
|
||||
rom_md5 = hl.md5(rom).hexdigest()
|
||||
@@ -6580,7 +6580,7 @@ struct BurnDriver BurnDrvneogeo = {
|
||||
import typing
|
||||
|
||||
from packs.platformpack import generate_pack
|
||||
from generate_pack import verify_pack_against_platform
|
||||
from packs.integrity import verify_pack_against_platform
|
||||
|
||||
self._create_region_fixtures()
|
||||
profiles = self._region_profiles()
|
||||
@@ -6668,7 +6668,7 @@ struct BurnDriver BurnDrvneogeo = {
|
||||
self.assertIn("All are included", text)
|
||||
|
||||
def test_verify_agrees_with_region_filtered_pack(self):
|
||||
from generate_pack import verify_pack_against_platform
|
||||
from packs.integrity import verify_pack_against_platform
|
||||
|
||||
out = self._region_pack(regions=["north-america"])
|
||||
result = verify_pack_against_platform(
|
||||
@@ -6683,7 +6683,7 @@ struct BurnDriver BurnDrvneogeo = {
|
||||
self.assertTrue(ok, errors)
|
||||
|
||||
def test_verify_reports_the_gap_without_the_region_filter(self):
|
||||
from generate_pack import verify_pack_against_platform
|
||||
from packs.integrity import verify_pack_against_platform
|
||||
|
||||
out = self._region_pack(regions=["north-america"])
|
||||
result = verify_pack_against_platform(
|
||||
|
||||
@@ -84,7 +84,7 @@ class BothConsumersAgree(unittest.TestCase):
|
||||
"""verify.py and generate_pack.py must answer the same for every mode."""
|
||||
|
||||
def test_builder_and_verifier_share_one_predicate(self):
|
||||
from generate_pack import _intentional_hash_exclusion
|
||||
from packs.integrity import _intentional_hash_exclusion
|
||||
from packs.verdicts import compute_severity
|
||||
|
||||
self.assertTrue(callable(compute_severity))
|
||||
|
||||
@@ -156,7 +156,7 @@ class ManifestsServeWhatTheCoreAccepts(unittest.TestCase):
|
||||
|
||||
from model.profiles import load_emulator_profiles
|
||||
from model.platforms import load_platform_config
|
||||
from generate_pack import _platform_cores
|
||||
from resolve.cores import resolve_platform_cores as _platform_cores
|
||||
from resolve.validation import check_file_validation
|
||||
|
||||
manifest_path = REPO_ROOT / "install" / "retroarch.json"
|
||||
|
||||
Reference in new issue
Block a user