refactor: one list of the names a core goes by

model.profiles.profile_names(key, profile) gives a profile's key then
the names its cores: lists, and core_key moves there from contentlayout
with core_key_index, upstream_profile_index keyed by it. The inline
{key, *cores} sets and scans in resolve and packs read profile_names;
the two roms folder matchers read core_key_index. The parameter of
select_emulator_profiles is renamed requested.

Matching stays exact everywhere it was exact. Folding case and -/_
everywhere would merge distinct profiles: dosbox_pure (Batocera,
AmberELEC, EmuELEC) would also name dosbox-pure-unleashed, and
pcsx_rearmed would also name pcsx_rearmed_standalone (RetroPie's
pcsx-rearmed). Only roms folder rows (retrobat BSNES, Snes9x, mGBA,
emudeck vice-x64sc...) depend on the fold, and those already fold.
The alias lookup of select_emulator_profiles now compares string core
names, as every other reader does. No output change.
This commit is contained in:
Abdessamad Derraz committed 2026-11-20 20:03:26 +01:00
1 parent 0095b23512
commit 48eb208786
10 files changed
+59 -38

No files matched your search

+2 -6
View File
@@ -18,17 +18,13 @@ from resolve.layout import (
standalone_layout_path,
)
from model.declarations import ROMS_ROOT, outer_layout
from model.profiles import core_key, profile_names
from core.paths import REPO_ROOT
LIBRETRO_RUNNERS = frozenset({"libretro", "retroarch", "retroarch32", "retrorun"})
def core_key(name: str) -> str:
"""A core name as two platforms spell it alike: mame2003-plus, mame2003_plus."""
return str(name).lower().replace("-", "_")
# Set on a platform config built for one board (generate_pack, verify
# --target): a core a roms folder offers on other boards only is not placed
# there.
@@ -403,7 +399,7 @@ def content_layout(
return {**view, "files": files}
if CONTENT_SCOPE_TAG not in tags:
return view
names = {core_key(n) for n in {emu_name, *(str(c) for c in view.get("cores") or [])}}
names = {core_key(n) for n in profile_names(emu_name, view)}
searches = [
json.loads(t[len(ROM_SEARCH_PREFIX):])
for t in tags if t.startswith(ROM_SEARCH_PREFIX)
+3 -3
View File
@@ -10,7 +10,7 @@ from core.cli import suggest_names
from core.paths import sanitize_pack_path
from model.declarations import declared_slot
from model.platforms import load_platform_config
from model.profiles import preferred_profile, upstream_profile_index
from model.profiles import preferred_profile, profile_names, upstream_profile_index
from model.systems import norm_system_id, select_systems
from model.targets import list_available_targets, load_target_config
from core.paths import REPO_ROOT
@@ -110,11 +110,11 @@ def _platform_profiles(
def replaced_by_own(name: str, p: dict, libretro_only: bool = False) -> bool:
if platform_key in (p.get("built_by") or []):
return False
names = {name, *(str(c) for c in p.get("cores") or [])}
names = set(profile_names(name, p))
return any(
(not libretro_only or "libretro" in str(q.get("type", "")))
and q.get("source") == p.get("source")
and names & {key, *(str(c) for c in q.get("cores") or [])}
and names.intersection(profile_names(key, q))
for key, q in own_builds.items()
)
+3 -4
View File
@@ -23,7 +23,7 @@ from dataclasses import dataclass
from core.hashing import parse_hash_list
from model.database import record_at
from model.declarations import CONFIGS_ROOT, ROMS_ROOT, declared_root, declared_slot, outer_layout
from model.profiles import lists_files
from model.profiles import lists_files, profile_names
from resolve.content import name_match_size_ok
from resolve.localfile import resolve_local_file
from core.paths import comparable_destination, sanitize_pack_path
@@ -434,8 +434,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 lists_files(profile)
and (key == part or part in {str(c) for c in profile.get("cores") or []})
if lists_files(profile) and part in profile_names(key, profile)
]
own = [k for k in named if platform in (profiles[k].get("built_by") or [])]
found.extend(own or [k for k in named if not profiles[k].get("built_by")])
@@ -1367,7 +1366,7 @@ class LauncherLayer:
key for key in relevant
if (profile := profiles.get(key)) is not None
and lists_files(profile)
and (key == name or name in {str(c) for c in profile.get("cores") or []})
and name in profile_names(key, profile)
)
def __bool__(self) -> bool:
+4 -2
View File
@@ -5,6 +5,8 @@ from __future__ import annotations
import json
from collections.abc import Iterable, Mapping
from model.profiles import profile_names
def runs_standalone(
@@ -97,7 +99,7 @@ def core_system_dirs(
]
if not pairs:
return None
names = {emu_name, *(str(c) for c in profile.get("cores") or [])}
names = set(profile_names(emu_name, profile))
return sorted({directory for core, directory in pairs if core in names})
@@ -239,7 +241,7 @@ def standalone_bindings_for(
if not declared and not pools:
return {}
names = {emu_name, *(str(c) for c in profile.get("cores") or [])}
names = set(profile_names(emu_name, profile))
layout = [
path for f in profile.get("files") or []
if isinstance(f, dict) and (path := standalone_layout_path(f, profile))
+2 -1
View File
@@ -18,6 +18,7 @@ from dataclasses import dataclass, field
from core.hashing import parse_hash_list
from model.profiles import profile_names
from model.systems import norm_system_id
from core.paths import REPO_ROOT
@@ -789,7 +790,7 @@ def _attach_runners(systems: dict[str, NativeSystem], scraped: dict | None) -> N
)
for key, as_standalone in layers:
profile = profiles.get(key, {})
names = [key, *(str(c) for c in profile.get("cores") or [])]
names = profile_names(key, profile)
if as_standalone:
name = next((n for n in names if n in standalone), None)
runner = (True, name) if name else None
+4 -4
View File
@@ -7,7 +7,7 @@ import json
from collections.abc import Iterable, Mapping
from dataclasses import dataclass
from model.profiles import load_emulator_profiles
from model.profiles import load_emulator_profiles, profile_names
from model.systems import norm_system_id
from resolve.contentlayout import content_folder_tags, content_layout
from resolve.layout import (
@@ -48,7 +48,7 @@ def own_build_tags(config: dict, standalone: set[str]) -> set[str]:
OWN_BUILD_PREFIX + json.dumps([n, key, p.get("source")])
for key, p in profiles.items()
if platform in (p.get("built_by") or []) and "standalone" in str(p.get("type", ""))
for n in {key, *(str(c) for c in p.get("cores") or [])} & standalone
for n in set(profile_names(key, p)) & standalone
}
@@ -72,7 +72,7 @@ def twin_build_names(config: dict) -> set[str]:
kind = str(profile.get("type", ""))
if "libretro" not in kind or "standalone" not in kind:
continue
names = {key, *(str(c) for c in profile.get("cores") or [])}
names = set(profile_names(key, profile))
if names & standalone:
found |= names & libretro
return found
@@ -193,7 +193,7 @@ class _StandaloneLaunches:
@classmethod
def of(cls, emu_name: str, profile: dict, standalone_cores: set[str]) -> _StandaloneLaunches:
names = {emu_name, *(str(c) for c in profile.get("cores") or [])}
names = set(profile_names(emu_name, profile))
per_system = bool(
profile.get("standalone_directories") or profile.get("standalone_pools")
) and any(h.systems and h.emulator in names for h in handed_from_tags(standalone_cores))