refactor: reuse the shared helpers left copied

Copies of helpers the first pass created, replaced by the helper:
- source_yaml_file for our YAML sources (generate_db read them in the
  locale's encoding, a syntax error named no file);
- data_dir_registry_at in registry_bundles, platform_registry_at (new,
  beside load_platform_registry) in the manifest;
- DATA_DIRS_FILE for the registry path five modules spelled;
- load_optional_database, sha1_at, VERSIONS_FILE, installer_module;
- DerivedView where a cache was keyed by id() of a dict;
- count_text and series where a plural or a list was written by hand.
This commit is contained in:
Abdessamad Derraz committed 2026-11-21 10:31:29 +01:00
1 parent 32a4ca1fa1
commit 036a6ebf29
35 files changed
+141 -170

No files matched your search

+2 -3
View File
@@ -28,7 +28,7 @@ sys.path.insert(0, os.path.dirname(__file__))
from core import upstream
from core.cli import add_repo_inputs, require_directory
from model.safeparse import yaml_load
from model.sources import source_yaml_file
from scraper.clex import blank_comments
from scraper.mame_parser import MACHINE_MACROS
@@ -62,8 +62,7 @@ def audit(
name: str, emulators_dir: str, cache_dir: str, offline: bool
) -> tuple[list[Finding], int, int]:
"""Findings, plus counts of refs that agree and of unjudgeable ones."""
with open(os.path.join(emulators_dir, f"{name}.yml"), encoding="utf-8") as handle:
document = yaml_load(handle) or {}
document = source_yaml_file(os.path.join(emulators_dir, f"{name}.yml")) or {}
trees = {
role: (upstream.parse_repo(str(document.get(role) or "")),
str(document.get(f"{role}_commit") or ""))