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:
Abdessamad Derraz committed 2026-11-20 20:03:26 +01:00
1 parent 200f785f67
commit 8f153e2b89
9 files changed
+25 -17

No files matched your search

+5
View File
@@ -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
+2 -2
View File
@@ -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"))