mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-24 10:37:54 -06:00
refactor: read entry systems with entry_system_ids
This commit is contained in:
1 parent
91b27854c8
commit
0107ac8062
4 files changed
+11
-28
No files matched your search
@@ -44,7 +44,7 @@ from pathlib import Path
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
|
||||
|
||||
from core.paths import EMULATORS_DIR, PLATFORMS_DIR
|
||||
from model.profiles import load_emulator_profiles
|
||||
from model.profiles import entry_system_ids, load_emulator_profiles
|
||||
from model.platforms import load_platform_config, native_layer
|
||||
from core.artifacts import repository_output_lock
|
||||
from core.cli import run_cli
|
||||
@@ -98,14 +98,6 @@ def _load_json(path: Path) -> dict:
|
||||
# --- Profiles ---------------------------------------------------------------
|
||||
|
||||
|
||||
def _entry_systems(profile: dict, entry: dict) -> set[str]:
|
||||
"""The systems a profile file serves: its own system field, else the profile's."""
|
||||
own = entry.get("system") or entry.get("systems")
|
||||
if own:
|
||||
return {own} if isinstance(own, str) else {str(s) for s in own}
|
||||
return {str(s) for s in profile.get("systems") or []}
|
||||
|
||||
|
||||
def _entry_names(entry: dict) -> set[str]:
|
||||
names = {str(entry.get("name") or "")}
|
||||
names |= {str(a) for a in entry.get("aliases") or []}
|
||||
@@ -136,7 +128,7 @@ class Profiles:
|
||||
|
||||
def serves(self, profile: str, entry: dict, system: str) -> bool:
|
||||
wanted = self.resolver.equivalents(system)
|
||||
return bool(_entry_systems(self.profiles.get(profile, {}), entry) & wanted)
|
||||
return bool(set(entry_system_ids(entry, self.profiles.get(profile, {}))) & wanted)
|
||||
|
||||
def region_files(self, profile: str, system: str) -> dict[str, list[str]]:
|
||||
"""Region slug -> file names the profile tags for it, for one system.
|
||||
|
||||
@@ -23,13 +23,13 @@ from core.hashing import file_digest
|
||||
from core.paths import REPO_ROOT
|
||||
from core.statefile import now_iso, save_state
|
||||
from model import measurements as mr
|
||||
from model.profiles import entry_system_ids
|
||||
from probes import rules
|
||||
from probes.profileedit import ProfileEditError, write_fields
|
||||
from probes.content import Content, ContentStore, load_content, load_file
|
||||
from probes.cores import Core, Cores
|
||||
from probes.entries import (
|
||||
entry_dest,
|
||||
entry_systems,
|
||||
held_file,
|
||||
is_bios,
|
||||
profile_digest,
|
||||
@@ -342,7 +342,7 @@ class Campaign:
|
||||
libretro = filter_files_by_mode(profile.get("files") or [], standalone=False)
|
||||
keep = {id(e) for e in libretro}
|
||||
return [(i, e) for i, e in enumerate(profile.get("files") or [])
|
||||
if id(e) in keep and system in entry_systems(e, profile) and is_bios(e)]
|
||||
if id(e) in keep and system in entry_system_ids(e, profile) and is_bios(e)]
|
||||
|
||||
def boot_entry(self, entries: list[tuple[int, dict]], content: Content) -> tuple[int, dict] | None:
|
||||
held = [(i, e) for i, e in entries if region_matches(e, content.region) and self.local_file(e)]
|
||||
|
||||
@@ -35,14 +35,6 @@ def held_file(entry: dict, db: dict, root: Path) -> Path | None:
|
||||
return local if local.is_file() else None
|
||||
|
||||
|
||||
def entry_systems(entry: dict, profile: dict) -> list[str]:
|
||||
if entry.get("systems"):
|
||||
return list(entry["systems"])
|
||||
if entry.get("system"):
|
||||
return [entry["system"]]
|
||||
return list(profile.get("systems") or [])
|
||||
|
||||
|
||||
def entry_dest(entry: dict) -> str:
|
||||
"""Where the core reads the entry, relative to its system directory."""
|
||||
path = entry.get("path")
|
||||
|
||||
@@ -13,6 +13,7 @@ from collections.abc import Callable, Iterable
|
||||
from pathlib import Path
|
||||
|
||||
from core.paths import REPO_ROOT
|
||||
from model.profiles import entry_system_ids
|
||||
from core_probe import BUILTIN
|
||||
from probes.content import Content, load_content, load_file
|
||||
from probes.cores import cached_nightly
|
||||
@@ -36,14 +37,12 @@ REGION_WORDS = {"japan": "Japanese", "north-america": "US", "europe": "European"
|
||||
|
||||
def region_entries(profile: dict, system: str) -> list[dict]:
|
||||
"""The BIOS entries of a system that a `region:` ties to territories."""
|
||||
out = []
|
||||
for entry in profile.get("files") or ():
|
||||
systems = entry.get("systems") or ([entry["system"]] if entry.get("system")
|
||||
else profile.get("systems") or [])
|
||||
if (system in systems and regions_of(entry) and "world" not in regions_of(entry)
|
||||
and entry.get("category", "bios") == "bios" and entry.get("mode") != "standalone"):
|
||||
out.append(entry)
|
||||
return out
|
||||
return [
|
||||
entry for entry in profile.get("files") or ()
|
||||
if system in entry_system_ids(entry, profile)
|
||||
and regions_of(entry) and "world" not in regions_of(entry)
|
||||
and entry.get("category", "bios") == "bios" and entry.get("mode") != "standalone"
|
||||
]
|
||||
|
||||
|
||||
def plan_variants(entries: Iterable[dict], region: str,
|
||||
|
||||
Reference in new issue
Block a user