mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-24 10:37:54 -06:00
refactor: read a platform's check mode one way
nativemode.platform_mode(config) replaces the inline
config.get("verification_mode", "existence") of the builder, the
manifest, slots, integrity, extras, gaps, coverage and review. A value
outside the schema enum now falls back to the default everywhere, as
coverage already did. Every platform declares a valid mode.
This commit is contained in:
1 parent
200f785f67
commit
8f153e2b89
9 files changed
+25
-17
No files matched your search
@@ -30,7 +30,7 @@ from packs.verdicts import (
|
||||
from resolve.categories import BIOS, EntryCategories
|
||||
from resolve.cores import platform_scope_systems, resolve_platform_cores
|
||||
from resolve.launchers import launcher_unproven
|
||||
from resolve.nativemode import digest_algorithm, normalize as normalize_mode, reads_file_contents
|
||||
from resolve.nativemode import digest_algorithm, platform_mode, reads_file_contents
|
||||
from resolve.validation import (
|
||||
build_validation_index,
|
||||
agnostic_substitute,
|
||||
@@ -773,7 +773,7 @@ def verify_platform(
|
||||
)
|
||||
# Normalized once: a typo in a platform YAML must not verify with one
|
||||
# mode and be scored with another.
|
||||
mode = normalize_mode(config.get("verification_mode"))
|
||||
mode = platform_mode(config)
|
||||
platform = config.get("platform", "unknown")
|
||||
|
||||
# The builder settles a destination claimed by both layers, and this must read
|
||||
|
||||
@@ -19,6 +19,7 @@ from model.declarations import declared_root, expand_platform_declared_names, pl
|
||||
from model.profiles import load_emulator_profiles
|
||||
from resolve.localfile import resolution_is_hash_exact
|
||||
from resolve.localfile import resolve_local_file
|
||||
from resolve.nativemode import platform_mode
|
||||
from resolve.cores import resolve_platform_cores
|
||||
from resolve.layout import core_system_dirs, system_dir_path
|
||||
from resolve.standalone import platform_layouts
|
||||
@@ -2129,7 +2130,7 @@ def _ships(
|
||||
if not path:
|
||||
return False
|
||||
return baseline_verdict(
|
||||
file_entry, path, status, config.get("verification_mode", "existence"),
|
||||
file_entry, path, status, platform_mode(config),
|
||||
config.get("hash_rule", ""),
|
||||
)[1] is None
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ from resolve.directories import expand_directory_entries
|
||||
from resolve.launchers import LauncherLayer, declared_destinations, held_record
|
||||
from resolve.layout import runs_standalone, system_dir_path
|
||||
from resolve.localfile import resolve_local_file
|
||||
from resolve.nativemode import hash_mismatch_excludes_file
|
||||
from resolve.nativemode import hash_mismatch_excludes_file, platform_mode
|
||||
from resolve.ownership import foreign_tree, owner_tokens
|
||||
from resolve.standalone import platform_layouts, standalone_set as platform_standalone_set
|
||||
from resolve.validation import (
|
||||
@@ -493,7 +493,7 @@ def find_undeclared_files(
|
||||
scan = _GapScan(
|
||||
config, db, data_names, include_all, declared_names, folded_slots,
|
||||
declared_contents,
|
||||
hash_mismatch_excludes_file(config.get("verification_mode")),
|
||||
hash_mismatch_excludes_file(platform_mode(config)),
|
||||
launcher_layer,
|
||||
)
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ from core.artifacts import build_timestamp
|
||||
from packs.paths import MEDIA_MARKER, has_path_conflict
|
||||
from core.ziptools import build_zip_contents_index
|
||||
from core.ziptools import check_inside_zip
|
||||
from resolve.nativemode import digest_algorithm
|
||||
from resolve.nativemode import digest_algorithm, platform_mode
|
||||
from resolve.validation import baseline_verdict, digest_verdict
|
||||
from resolve.nativemode import hash_mismatch_excludes_file
|
||||
import hashlib
|
||||
@@ -593,7 +593,7 @@ def _builder_extras(
|
||||
config, emu_profiles = expect.config, expect.emu_profiles
|
||||
data_registry = expect.opts.data_registry
|
||||
base_dest = expect.base_dest
|
||||
mode = config.get("verification_mode", "existence")
|
||||
mode = platform_mode(config)
|
||||
hash_rule = config.get("hash_rule", "")
|
||||
shipped: dict[str, str | None] = {}
|
||||
for expected, declarations in baseline_groups.items():
|
||||
@@ -857,7 +857,7 @@ def _count_baseline(
|
||||
db,
|
||||
zip_contents=exclusion_index,
|
||||
data_dir_registry=data_registry,
|
||||
verification_mode=expect.config.get("verification_mode", "existence"),
|
||||
verification_mode=platform_mode(expect.config),
|
||||
hash_rule=expect.config.get("hash_rule", ""),
|
||||
):
|
||||
count.excluded += 1
|
||||
@@ -895,7 +895,7 @@ def _native_hash_errors(
|
||||
# error when the repo holds a file matching a declaration: without
|
||||
# one, the pack ships its best effort and the gap is a data issue
|
||||
# reported by verify.py, not a generation bug.
|
||||
verification_mode = config.get("verification_mode", "existence")
|
||||
verification_mode = platform_mode(config)
|
||||
digest = digest_algorithm(verification_mode)
|
||||
hash_rule = config.get("hash_rule", "")
|
||||
errors: list[str] = []
|
||||
|
||||
@@ -59,7 +59,7 @@ from packs.standalone import standalone_copies, standalone_layouts
|
||||
from resolve.contentlayout import TARGET_KEY
|
||||
from resolve.cores import filter_systems_by_target, resolve_platform_cores as _platform_cores
|
||||
from resolve.gamedata import GAME_DATA, is_game_data, platform_game_data, without_game_data
|
||||
from resolve.nativemode import digest_algorithm, reads_file_contents
|
||||
from resolve.nativemode import digest_algorithm, platform_mode, reads_file_contents
|
||||
from resolve.packfiles import preferred_entries as _preferred_entries, resolve_declaration
|
||||
from resolve.validation import (
|
||||
build_validation_index,
|
||||
@@ -189,7 +189,7 @@ class _ManifestBuild:
|
||||
|
||||
@property
|
||||
def verification_mode(self) -> str:
|
||||
return self.config.get("verification_mode", "existence")
|
||||
return platform_mode(self.config)
|
||||
|
||||
@property
|
||||
def fields(self) -> SelectionIndex:
|
||||
|
||||
@@ -50,7 +50,9 @@ from resolve import packfiles as packresolve, regions as resolve_regions, slot a
|
||||
from resolve.contentlayout import TARGET_KEY
|
||||
from resolve.cores import platform_scope_systems, system_scope_error
|
||||
from resolve.gamedata import GameDataCut, without_game_data
|
||||
from resolve.nativemode import digest_algorithm, hash_mismatch_excludes_file, reads_file_contents
|
||||
from resolve.nativemode import (
|
||||
digest_algorithm, hash_mismatch_excludes_file, platform_mode, reads_file_contents,
|
||||
)
|
||||
from resolve.packfiles import (
|
||||
download_external,
|
||||
preferred_entries as _preferred_entries,
|
||||
@@ -361,7 +363,7 @@ class _PlatformPlan:
|
||||
|
||||
@property
|
||||
def verification_mode(self) -> str:
|
||||
return self.config.get("verification_mode", "existence")
|
||||
return platform_mode(self.config)
|
||||
|
||||
@property
|
||||
def platform_display(self) -> str:
|
||||
|
||||
@@ -397,7 +397,7 @@ def _slot_claims(
|
||||
# pins an md5 nobody holds, and the primary shipped without the 000-lo.lo
|
||||
# geolith and FBNeo read inside it. Decided per entry: EmuDeck, an md5
|
||||
# platform, declares the same archive with no hash.
|
||||
mode = config.get("verification_mode", "existence")
|
||||
mode = nativemode.platform_mode(config)
|
||||
rule = config.get("hash_rule", "")
|
||||
by_slot: dict[str, list[Claim]] = {}
|
||||
for claim in profile_claims(
|
||||
@@ -535,7 +535,7 @@ def slot_choices(
|
||||
recorded whole in the install manifest, so a target narrowed from the
|
||||
full manifest gets the bytes the target's own pack carries.
|
||||
"""
|
||||
mode = config.get("verification_mode", "existence")
|
||||
mode = nativemode.platform_mode(config)
|
||||
rule = config.get("hash_rule", "")
|
||||
platform_profiles = {
|
||||
name: profiles[name] for name in resolve_platform_cores(config, profiles)
|
||||
|
||||
@@ -57,6 +57,11 @@ def normalize(mode: str | None) -> str:
|
||||
return mode if mode in MODES else DEFAULT_MODE
|
||||
|
||||
|
||||
def platform_mode(config: dict) -> str:
|
||||
"""The mode a platform config declares, the schema default when it declares none."""
|
||||
return normalize(config.get("verification_mode"))
|
||||
|
||||
|
||||
def reads_file_contents(mode: str | None) -> bool:
|
||||
"""Whether the frontend opens the file rather than just finding it."""
|
||||
return normalize(mode) in MODE_DIGEST
|
||||
|
||||
@@ -20,7 +20,7 @@ from model.nodedup import in_nodedup_dir
|
||||
from model.platforms import load_platform_config
|
||||
from model.profiles import load_emulator_profiles
|
||||
from model.registry import list_registered_platforms
|
||||
from resolve.nativemode import digest_algorithm
|
||||
from resolve.nativemode import digest_algorithm, platform_mode
|
||||
from resolve.validation import frontend_digest_matches, inner_rom_check
|
||||
|
||||
if TYPE_CHECKING:
|
||||
@@ -175,7 +175,7 @@ def load_platform_hashes(platforms_dir: str, db: dict | None = None) -> dict:
|
||||
print(f"WARNING: {name}: {exc}", file=sys.stderr)
|
||||
continue
|
||||
|
||||
mode, rule = config.get("verification_mode"), config.get("hash_rule", "")
|
||||
mode, rule = platform_mode(config), config.get("hash_rule", "")
|
||||
for system_id, system in config.get("systems", {}).items():
|
||||
for file_entry in system.get("files", []):
|
||||
sha1s = parse_hash_list(file_entry.get("sha1"))
|
||||
|
||||
Reference in new issue
Block a user