mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-25 10:58:52 -06:00
refactor: name the profile kinds in model.profiles
lists_files(profile) answers whether a profile declares files, false for a launcher or an alias, and is_emulator(profile) whether it counts as an emulator, false for an alias or a test core. Eighteen inline checks in model, resolve and packs read them; each keeps the set it tested. model.systems keeps its own check: it sits below model.profiles. No behavior change.
This commit is contained in:
1 parent
b679edb133
commit
899f591575
13 files changed
+46
-25
No files matched your search
@@ -13,7 +13,7 @@ except ImportError:
|
||||
yaml = None
|
||||
|
||||
from model.platforms import load_platform_config
|
||||
from model.profiles import load_emulator_profiles
|
||||
from model.profiles import is_emulator, load_emulator_profiles
|
||||
from model.registry import list_registered_platforms, list_release_pack_platforms
|
||||
from model.systems import platform_system_names, system_index
|
||||
from core.paths import PLATFORMS_DIR, REPO_ROOT
|
||||
@@ -92,7 +92,7 @@ def list_emulator_profiles(emulators_dir: str, skip_aliases: bool = True) -> Non
|
||||
profiles = load_emulator_profiles(emulators_dir, skip_aliases=False)
|
||||
for name in sorted(profiles):
|
||||
p = profiles[name]
|
||||
if p.get("type") == "alias" or p.get("role") == "test":
|
||||
if not is_emulator(p):
|
||||
continue
|
||||
display = p.get("emulator", name)
|
||||
ptype = p.get("type", "libretro")
|
||||
|
||||
@@ -13,7 +13,7 @@ from dataclasses import dataclass
|
||||
|
||||
from model import siteinputs
|
||||
from model.composition import GAME_DATA_TOPS
|
||||
from model.profiles import load_emulator_profiles
|
||||
from model.profiles import is_emulator, load_emulator_profiles
|
||||
|
||||
|
||||
def copy_places(db: dict) -> dict[str, set[tuple[str, str, str]]]:
|
||||
@@ -95,7 +95,7 @@ def _engine_sections(manufacturers: dict[str, dict[str, list]]) -> dict[str, dic
|
||||
"""
|
||||
|
||||
profiles = {key: profile for key, profile in profiles_on_disk().items()
|
||||
if profile.get("type") != "alias" and profile.get("role") != "test"}
|
||||
if is_emulator(profile)}
|
||||
engines = _Engines(profiles, _file_readers(profiles))
|
||||
out: dict[str, dict[str, list]] = {}
|
||||
for mfr, consoles in manufacturers.items():
|
||||
|
||||
@@ -27,6 +27,22 @@ 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"
|
||||
|
||||
|
||||
class ProfileSelectionError(ValueError):
|
||||
"""A named profile cannot answer for itself."""
|
||||
|
||||
@@ -43,7 +59,7 @@ def profiles_for_systems(
|
||||
wanted = {norm_system_id(sid) for sid in system_ids}
|
||||
matching = []
|
||||
for name, profile in sorted(profiles.items()):
|
||||
if profile.get("type") in ("launcher", "alias") or profile.get("role") == "test":
|
||||
if not lists_files(profile) or profile.get("role") == "test":
|
||||
continue
|
||||
if standalone and "standalone" not in profile.get("type", "libretro"):
|
||||
continue
|
||||
@@ -121,7 +137,7 @@ def select_emulator_profiles(
|
||||
available = sorted(
|
||||
key
|
||||
for key, value in all_profiles.items()
|
||||
if value.get("type") != "alias" and value.get("role") != "test"
|
||||
if is_emulator(value)
|
||||
)
|
||||
raise ProfileSelectionError(
|
||||
f"emulator '{name}' not found\n"
|
||||
@@ -264,7 +280,7 @@ def _normalize_hash_fields(node: object) -> None:
|
||||
def unique_emulator_profiles(profiles: dict[str, dict]) -> dict[str, dict]:
|
||||
"""Profiles counting as distinct emulators (aliases and tests excluded)."""
|
||||
return {
|
||||
k: v for k, v in profiles.items() if v.get("type") != "alias" and v.get("role") != "test"
|
||||
k: v for k, v in profiles.items() if is_emulator(v)
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user