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

+4 -3
View File
@@ -25,6 +25,8 @@ from model.platforms import load_platform_config
from model.profiles import source_yaml_paths
from core.artifacts import write_text_atomic
from model.safeparse import yaml_load
from model.sources import source_yaml_file
from core.cli import SourceUnreadable
from core import upstream
@@ -123,8 +125,7 @@ def _find_mame_profiles() -> list[Path]:
profiles: list[Path] = []
for path in source_yaml_paths(_EMULATORS_DIR):
try:
with open(path, encoding="utf-8") as f:
data = yaml_load(f)
data = source_yaml_file(path)
if not isinstance(data, dict):
continue
upstream = data.get("upstream", "")
@@ -149,7 +150,7 @@ def _find_mame_profiles() -> list[Path]:
)
):
profiles.append(path)
except (yaml.YAMLError, OSError) as exc:
except (SourceUnreadable, OSError) as exc:
# Skipped, a broken mame.yml left the list and the refresh
# reported success without touching it.
raise RuntimeError(f"cannot read {path}: {exc}") from exc