mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-24 18:47:53 -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)
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ from core.paths import BIOS_DIR, EMULATORS_DIR, declared_destination
|
||||
from core.ziptools import build_zip_contents_index
|
||||
from model.alternatives import core_file_spares
|
||||
from model.declarations import OUTER_ROOTS, platform_declarations
|
||||
from model.profiles import load_emulator_profiles
|
||||
from model.profiles import lists_files, load_emulator_profiles
|
||||
from model.systems import select_systems
|
||||
from packs import slots
|
||||
from packs.crossref import launcher_reads_not_held
|
||||
@@ -707,7 +707,7 @@ def _profile_coverage(
|
||||
gt_filenames = set(validation_index)
|
||||
profiled_names: set[str] = set()
|
||||
for profile in profiles.values():
|
||||
if profile.get("type") in ("launcher", "alias"):
|
||||
if not lists_files(profile):
|
||||
continue
|
||||
for f in profile.get("files", []):
|
||||
name = f.get("name", "")
|
||||
|
||||
@@ -16,6 +16,7 @@ from core.hashing import parse_hash_list, parse_md5_list, stream_hashes
|
||||
from core.paths import BIOS_DIR, PLATFORMS_DIR, REPO_ROOT
|
||||
from model.alternatives import set_keys, set_requirements, settle_sets
|
||||
from model.database import get_mame_clone_map
|
||||
from model.profiles import lists_files
|
||||
from model.declarations import OUTER_ROOTS
|
||||
from model.platforms import load_platform_config
|
||||
from model.registry import list_registered_platforms, load_data_dir_registry
|
||||
@@ -1132,7 +1133,7 @@ def _profile_names(profiles: dict[str, dict]) -> tuple[dict[str, list[dict]], di
|
||||
exact: dict[str, list[dict]] = {}
|
||||
folded: dict[str, list[dict]] = {}
|
||||
for profile in profiles.values():
|
||||
if profile.get("type") in ("launcher", "alias"):
|
||||
if not lists_files(profile):
|
||||
continue
|
||||
for entry in profile.get("files") or []:
|
||||
names = {str(entry.get("name") or "")} | {str(a) for a in entry.get("aliases") or []}
|
||||
|
||||
@@ -11,7 +11,7 @@ from dataclasses import dataclass, field
|
||||
from typing import TYPE_CHECKING, TypedDict
|
||||
|
||||
from core.options import reject_unknown
|
||||
from model.profiles import PROFILE_IDENTITY_FIELDS, entry_system_ids
|
||||
from model.profiles import PROFILE_IDENTITY_FIELDS, entry_system_ids, lists_files
|
||||
from model.systems import norm_system_id
|
||||
from model.alternatives import core_file_spares, required_only_spares, set_fields
|
||||
from resolve.archives import archive_members, contents_members, holds_required_members
|
||||
@@ -619,7 +619,7 @@ def _agnostic_scan_extras(
|
||||
# Third pass: the agnostic scan. For filename-agnostic cores, include all
|
||||
# DB files matching the system path prefix and size criteria.
|
||||
for emu_name, profile in sorted(profiles.items()):
|
||||
if profile.get("type") in ("launcher", "alias"):
|
||||
if not lists_files(profile):
|
||||
continue
|
||||
if emu_name not in relevant:
|
||||
continue
|
||||
@@ -1193,7 +1193,7 @@ def _archive_prefix_extras(
|
||||
# the root, add a copy at the prefixed path so the core's .info firmware
|
||||
# check finds it.
|
||||
for emu_name, profile in sorted(profiles.items()):
|
||||
if profile.get("type") in ("launcher", "alias"):
|
||||
if not lists_files(profile):
|
||||
continue
|
||||
if emu_name not in relevant:
|
||||
continue
|
||||
@@ -1564,7 +1564,7 @@ def collect_emulator_extras(
|
||||
extras_prefix,
|
||||
)
|
||||
for emu_name, profile in sorted(profiles.items()):
|
||||
if profile.get("type") in ("launcher", "alias"):
|
||||
if not lists_files(profile):
|
||||
continue
|
||||
if emu_name not in relevant:
|
||||
continue
|
||||
|
||||
@@ -8,7 +8,7 @@ from dataclasses import dataclass, field
|
||||
|
||||
from model.alternatives import set_fields, set_keys, set_requirements, settle_sets
|
||||
from model.declarations import OUTER_ROOTS, platform_declarations, platform_declared_contents
|
||||
from model.profiles import PROFILE_IDENTITY_FIELDS, entry_system_ids, load_emulator_profiles
|
||||
from model.profiles import PROFILE_IDENTITY_FIELDS, entry_system_ids, lists_files, load_emulator_profiles
|
||||
from packs.paths import core_save_folder
|
||||
from resolve.archives import archive_entry, archive_members
|
||||
from resolve.cores import resolve_platform_cores
|
||||
@@ -498,7 +498,7 @@ def find_undeclared_files(
|
||||
)
|
||||
|
||||
for emu_name, profile in sorted(profiles.items()):
|
||||
if profile.get("type") in ("launcher", "alias"):
|
||||
if not lists_files(profile):
|
||||
continue
|
||||
if emu_name not in relevant:
|
||||
continue
|
||||
|
||||
@@ -7,7 +7,7 @@ from dataclasses import dataclass, field
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from core.hashing import parse_md5_list
|
||||
from model.profiles import entry_system_ids
|
||||
from model.profiles import entry_system_ids, lists_files
|
||||
from resolve import nativemode
|
||||
from resolve.archives import archive_entry, holds_required_members
|
||||
from resolve.collisions import accepted_by_all, content_sha1, lists_hashes, comparable_destination
|
||||
@@ -170,7 +170,7 @@ def profile_claims(
|
||||
placement = ExtraPlacement(config, base_dest, profiles)
|
||||
claims: list[Claim] = []
|
||||
for emu_name, profile in sorted(profiles.items()):
|
||||
if profile.get("type") in ("launcher", "alias"):
|
||||
if not lists_files(profile):
|
||||
continue
|
||||
# The gap report skips a filename-agnostic profile whole: the builder
|
||||
# carries its scan candidates, never its named entries.
|
||||
|
||||
@@ -22,6 +22,7 @@ from dataclasses import dataclass
|
||||
|
||||
from core.hashing import parse_hash_list
|
||||
from model.declarations import CONFIGS_ROOT, ROMS_ROOT, declared_root, outer_layout
|
||||
from model.profiles import lists_files
|
||||
from resolve.content import name_match_size_ok
|
||||
from resolve.localfile import resolve_local_file
|
||||
from core.paths import sanitize_pack_path
|
||||
@@ -432,7 +433,7 @@ def _named_profiles(record: dict, profiles: Mapping[str, dict], platform: str) -
|
||||
for part in (e.strip() for e in str(record.get("emulator", "")).split(",")):
|
||||
named = [
|
||||
key for key, profile in profiles.items()
|
||||
if profile.get("type") not in ("alias", "launcher")
|
||||
if lists_files(profile)
|
||||
and (key == part or part in {str(c) for c in profile.get("cores") or []})
|
||||
]
|
||||
own = [k for k in named if platform in (profiles[k].get("built_by") or [])]
|
||||
@@ -1369,7 +1370,7 @@ class LauncherLayer:
|
||||
return sorted(
|
||||
key for key in relevant
|
||||
if (profile := profiles.get(key)) is not None
|
||||
and profile.get("type") not in ("alias", "launcher")
|
||||
and lists_files(profile)
|
||||
and (key == name or name in {str(c) for c in profile.get("cores") or []})
|
||||
)
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ import re
|
||||
|
||||
from model import region
|
||||
from model.region import NOINTRO
|
||||
from model.profiles import lists_files
|
||||
from resolve.localfile import resolve_local_file
|
||||
|
||||
|
||||
@@ -70,7 +71,7 @@ def build_report(profiles: dict, db: dict) -> dict:
|
||||
|
||||
by_path = {entry.get("path", ""): sha1 for sha1, entry in db["files"].items()}
|
||||
for emu_name, profile in sorted(profiles.items()):
|
||||
if profile.get("type") in ("launcher", "alias"):
|
||||
if not lists_files(profile):
|
||||
continue
|
||||
for f in profile.get("files") or []:
|
||||
if not isinstance(f, dict) or not f.get("region"):
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from model.profiles import lists_files
|
||||
from model.region import WORLD, normalize_declared, rank
|
||||
from resolve.slot import lookup_slot
|
||||
|
||||
@@ -31,7 +32,7 @@ def build_region_index(profiles: dict) -> dict[str, dict]:
|
||||
"""
|
||||
index: dict[str, dict] = {}
|
||||
for emu_name, profile in sorted(profiles.items()):
|
||||
if profile.get("type") in ("launcher", "alias"):
|
||||
if not lists_files(profile):
|
||||
continue
|
||||
for f in profile.get("files") or []:
|
||||
if not isinstance(f, dict):
|
||||
|
||||
@@ -30,6 +30,7 @@ rank: the second core reads it by its own rule, which no rank expresses.
|
||||
from __future__ import annotations
|
||||
|
||||
from model.alternatives import set_keys
|
||||
from model.profiles import lists_files
|
||||
|
||||
BIOS_CATEGORY = "bios"
|
||||
|
||||
@@ -69,7 +70,7 @@ def slot_claims(profiles: dict) -> dict[str, dict[str, dict]]:
|
||||
"""
|
||||
claims: dict[str, dict[str, dict]] = {}
|
||||
for emu_name, profile in sorted(profiles.items()):
|
||||
if profile.get("type") in ("launcher", "alias"):
|
||||
if not lists_files(profile):
|
||||
continue
|
||||
for f in profile.get("files") or []:
|
||||
if not isinstance(f, dict):
|
||||
|
||||
@@ -21,7 +21,7 @@ from resolve.content import (
|
||||
shape_fits,
|
||||
)
|
||||
from resolve.archives import archive_members
|
||||
from model.profiles import CONTENT_CHECKS, entry_system_ids
|
||||
from model.profiles import CONTENT_CHECKS, entry_system_ids, lists_files
|
||||
from core.hashing import compute_hashes, parse_hash_list
|
||||
from core.paths import BIOS_DIR, sanitize_pack_path
|
||||
from core.hashing import md5_composite, parse_md5_list
|
||||
@@ -385,7 +385,7 @@ def build_validation_index(profiles: dict) -> dict[str, dict]:
|
||||
unchecked: set[tuple[str, str, str]] = set()
|
||||
checked: set[tuple[str, str, str]] = set()
|
||||
for emu_name, profile in profiles.items():
|
||||
if profile.get("type") in ("launcher", "alias"):
|
||||
if not lists_files(profile):
|
||||
continue
|
||||
for f in _labels_widened(profile):
|
||||
fname = f.get("name", "")
|
||||
|
||||
Reference in new issue
Block a user