mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-22 17:47:48 -06:00
refactor: move profile kinds to their own module
model.systems kept an inline copy of reads_own_files because model.profiles imports it. The predicates live in model.profilekinds, which both import, and model.profiles re-exports them. sitegen.build reads lists_files instead of its own launcher/alias tuple.
This commit is contained in:
1 parent
780d40fb7b
commit
71776198e9
5 files changed
+31
-24
No files matched your search
@@ -54,6 +54,7 @@ on:
|
||||
- "scripts/model/nodedup.py"
|
||||
- "scripts/model/platforms.py"
|
||||
- "scripts/model/profiles.py"
|
||||
- "scripts/model/profilekinds.py"
|
||||
- "scripts/model/region.py"
|
||||
- "scripts/model/registry.py"
|
||||
- "scripts/model/releaserecord.py"
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
"""What kind of profile a profile is: an emulator, an alias, a launcher, a test core."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
# A launcher hands the game to another emulator and an alias is another
|
||||
# profile's build under a second name: neither declares files of its own.
|
||||
FILELESS_TYPES = frozenset({"launcher", "alias"})
|
||||
|
||||
|
||||
def lists_files(profile: dict) -> bool:
|
||||
"""Whether a profile declares the files its emulator reads."""
|
||||
return profile.get("type") not in FILELESS_TYPES
|
||||
|
||||
|
||||
def is_emulator(profile: dict) -> bool:
|
||||
"""Whether a profile counts as an emulator of its own, neither an alias
|
||||
nor a test core."""
|
||||
return profile.get("type") != "alias" and profile.get("role") != "test"
|
||||
|
||||
|
||||
def reads_own_files(profile: dict) -> bool:
|
||||
"""Whether a profile lists the files its emulator reads and is not a test core."""
|
||||
return lists_files(profile) and profile.get("role") != "test"
|
||||
@@ -14,6 +14,9 @@ except ImportError:
|
||||
|
||||
from core.cli import InputMissing, suggest_names
|
||||
from model.alternatives import derive_member_requirements
|
||||
from model.profilekinds import is_emulator as is_emulator
|
||||
from model.profilekinds import lists_files as lists_files
|
||||
from model.profilekinds import reads_own_files as reads_own_files
|
||||
from model.sources import source_yaml_file
|
||||
from model.systems import norm_system_id, system_index
|
||||
from core.paths import REPO_ROOT
|
||||
@@ -27,27 +30,6 @@ CONTENT_CHECKS = frozenset({"romdir", "masked_sha1"})
|
||||
emulator_profiles_cache: dict[tuple[str, bool], dict[str, dict]] = {}
|
||||
|
||||
|
||||
# A launcher hands the game to another emulator and an alias is another
|
||||
# profile's build under a second name: neither declares files of its own.
|
||||
FILELESS_TYPES = frozenset({"launcher", "alias"})
|
||||
|
||||
|
||||
def lists_files(profile: dict) -> bool:
|
||||
"""Whether a profile declares the files its emulator reads."""
|
||||
return profile.get("type") not in FILELESS_TYPES
|
||||
|
||||
|
||||
def is_emulator(profile: dict) -> bool:
|
||||
"""Whether a profile counts as an emulator of its own, neither an alias
|
||||
nor a test core."""
|
||||
return profile.get("type") != "alias" and profile.get("role") != "test"
|
||||
|
||||
|
||||
def reads_own_files(profile: dict) -> bool:
|
||||
"""Whether a profile lists the files its emulator reads and is not a test core."""
|
||||
return lists_files(profile) and profile.get("role") != "test"
|
||||
|
||||
|
||||
class ProfileSelectionError(ValueError):
|
||||
"""A named profile cannot answer for itself."""
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import re
|
||||
|
||||
from core.cli import suggest_names
|
||||
from model.platforms import native_layer
|
||||
from model.profilekinds import reads_own_files
|
||||
|
||||
|
||||
MANUFACTURER_PREFIXES = (
|
||||
@@ -332,7 +333,7 @@ def system_index(profiles: dict) -> dict[str, tuple[str, set[str]]]:
|
||||
"""
|
||||
index: dict[str, tuple[str, set[str]]] = {}
|
||||
for name, p in sorted(profiles.items()):
|
||||
if p.get("type") in ("alias", "launcher") or p.get("role") == "test":
|
||||
if not reads_own_files(p):
|
||||
continue
|
||||
for sys_id in p.get("systems", []):
|
||||
key = norm_system_id(sys_id)
|
||||
|
||||
@@ -20,7 +20,7 @@ from model.composition import compute_composition
|
||||
from model.database import load_database
|
||||
from model.dumpcatalog import load_provenance_snapshots
|
||||
from model.guides import HANDHELD_GUIDE
|
||||
from model.profiles import is_emulator, load_emulator_profiles
|
||||
from model.profiles import is_emulator, lists_files, load_emulator_profiles
|
||||
from model.registry import list_registered_platforms, load_platform_registry
|
||||
from model.systemnames import program_names, set_console_sections, system_name
|
||||
from packs.crossref import FileConsumers
|
||||
@@ -433,7 +433,7 @@ def _write_emulator_page(run: _SiteRun, name: str, profile: dict) -> None:
|
||||
# A frozen copy answers after the emulator: a frozen_snapshot, and a
|
||||
# profile pinned to the revision one platform builds (pin_frozen).
|
||||
# Reicast and Flycast 2021 LE answered "dc bios missing" before Flycast.
|
||||
if (profile.get("type") in ("launcher", "alias")
|
||||
if (not lists_files(profile)
|
||||
or profile.get("core_classification") in ("launcher", "alias", "frozen_snapshot")
|
||||
or profile.get("pin_frozen")):
|
||||
SEARCH_DEMOTED.add(f"emulators/{name}.md")
|
||||
|
||||
Reference in new issue
Block a user