refactor: leave the commands their own code

This commit is contained in:
Abdessamad Derraz committed 2026-11-18 13:47:56 +01:00
1 parent 1f8e106974
commit 27330be60a
17 files changed
+47 -72

No files matched your search

-3
View File
@@ -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,
+1 -23
View File
@@ -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
+3
View File
@@ -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",
+3
View File
@@ -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.
+3
View File
@@ -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."""
+3
View File
@@ -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.
+3
View File
@@ -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 = {}
+3
View File
@@ -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
+3
View File
@@ -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.
+9
View File
@@ -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.
-3
View File
@@ -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
-3
View File
@@ -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
-25
View File
@@ -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: