mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-22 17:47:48 -06:00
refactor: name the emulator profile filters
This commit is contained in:
1 parent
8fdc00e07f
commit
91b27854c8
15 files changed
+42
-27
No files matched your search
@@ -43,6 +43,11 @@ def is_emulator(profile: dict) -> bool:
|
||||
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."""
|
||||
|
||||
@@ -59,7 +64,7 @@ def profiles_for_systems(
|
||||
wanted = {norm_system_id(sid) for sid in system_ids}
|
||||
matching = []
|
||||
for name, profile in sorted(profiles.items()):
|
||||
if not lists_files(profile) or profile.get("role") == "test":
|
||||
if not reads_own_files(profile):
|
||||
continue
|
||||
if standalone and "standalone" not in profile.get("type", "libretro"):
|
||||
continue
|
||||
|
||||
+2
-1
@@ -79,6 +79,7 @@ from core.artifacts import (
|
||||
)
|
||||
from core.github import github_token
|
||||
from model.registry import load_data_dir_registry
|
||||
from model.profiles import reads_own_files
|
||||
from packs.datadirs import hold_data_dirs
|
||||
from packs.paths import MEDIA_MARKER
|
||||
|
||||
@@ -647,7 +648,7 @@ def check_emulator_packs(
|
||||
systems = sorted({
|
||||
norm_system_id(str(sid))
|
||||
for profile in profiles.values()
|
||||
if profile.get("type") not in ("launcher", "alias") and profile.get("role") != "test"
|
||||
if reads_own_files(profile)
|
||||
for sid in profile.get("systems") or []
|
||||
})
|
||||
systems_ok = True
|
||||
|
||||
@@ -24,7 +24,7 @@ from core import upstream
|
||||
from profiling import version_basis
|
||||
from model.systems import norm_system_id, system_index
|
||||
from core.github import github_token
|
||||
from model.profiles import load_emulator_profiles
|
||||
from model.profiles import is_emulator, load_emulator_profiles
|
||||
from core.cli import add_repo_inputs, suggest_names
|
||||
from profiling.bump import DEFAULT_CACHE, write_version
|
||||
from profiling.realign import realign_prose
|
||||
@@ -315,7 +315,7 @@ def select_profiles(profiles: dict, args: argparse.Namespace) -> dict:
|
||||
# alias and test profiles too, "lists all 553" pointed at 530 lines.
|
||||
listed = sorted(
|
||||
name for name, profile in profiles.items()
|
||||
if profile.get("type") != "alias" and profile.get("role") != "test"
|
||||
if is_emulator(profile)
|
||||
)
|
||||
raise SystemExit(
|
||||
f"ERROR: unknown profile {', '.join(unknown)}. "
|
||||
@@ -328,7 +328,7 @@ def select_profiles(profiles: dict, args: argparse.Namespace) -> dict:
|
||||
wanted_system = norm_system_id(args.system) if args.system else None
|
||||
selected = {}
|
||||
for name, profile in sorted(profiles.items()):
|
||||
if profile.get("type") == "alias" or profile.get("role") == "test":
|
||||
if not is_emulator(profile):
|
||||
continue
|
||||
if wanted_system and wanted_system not in {
|
||||
norm_system_id(str(s)) for s in profile.get("systems") or []
|
||||
|
||||
@@ -8,6 +8,7 @@ from collections.abc import Callable
|
||||
from model.collection import group_by_manufacturer, manufacturer_slug
|
||||
from model.database import sha1_at
|
||||
from model.systemnames import system_name
|
||||
from model.profiles import is_emulator
|
||||
from sitegen.config import SITE_URL
|
||||
from sitegen.lookup import sorted_hash_values, site_path
|
||||
from sitegen.render import console_href
|
||||
@@ -35,7 +36,7 @@ def system_index_items(db: dict, coverages: dict, profiles: dict) -> list[dict]:
|
||||
if sha1:
|
||||
held.setdefault(str(detail.get("system", "")), set()).add(sha1)
|
||||
for profile in profiles.values():
|
||||
if profile.get("type") == "alias" or profile.get("role") == "test":
|
||||
if not is_emulator(profile):
|
||||
continue
|
||||
own = [str(s) for s in profile.get("systems") or []]
|
||||
for entry in profile.get("files") or []:
|
||||
@@ -86,7 +87,7 @@ def _first_file_place(
|
||||
return parts[1], site_path(f"systems/{page}.md#sha1-{sha1[:12]}")
|
||||
for key in sorted(profiles):
|
||||
profile = profiles[key]
|
||||
if profile.get("type") != "alias" and profile.get("role") != "test" and sys_id in (profile.get("systems") or []):
|
||||
if is_emulator(profile) and sys_id in (profile.get("systems") or []):
|
||||
return "", site_path(f"emulators/{key}.md")
|
||||
return "", None
|
||||
|
||||
@@ -101,7 +102,7 @@ def core_index_items(profiles: dict) -> list[dict]:
|
||||
"""
|
||||
from model.profiles import preferred_profile, upstream_profile_index
|
||||
|
||||
published = {name for name, p in profiles.items() if p.get("type") != "alias" and p.get("role") != "test"}
|
||||
published = {name for name, p in profiles.items() if is_emulator(p)}
|
||||
index = upstream_profile_index(profiles)
|
||||
for name, profile in profiles.items():
|
||||
target = str(profile.get("alias_of") or "")
|
||||
|
||||
@@ -19,7 +19,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 load_emulator_profiles
|
||||
from model.profiles import is_emulator, 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
|
||||
@@ -379,7 +379,7 @@ def _record_data_trees(profiles: dict) -> None:
|
||||
DATA_MEMBERS.update(data_directory_members())
|
||||
DATA_REVISIONS.update(data_directory_revisions())
|
||||
for key in sorted(profiles):
|
||||
if profiles[key].get("type") == "alias" or profiles[key].get("role") == "test":
|
||||
if not is_emulator(profiles[key]):
|
||||
continue
|
||||
display = str(profiles[key].get("emulator", key))
|
||||
for tree in page_data_directories(key, profiles):
|
||||
@@ -403,7 +403,7 @@ def _write_emulator_pages(run: _SiteRun) -> None:
|
||||
public_profiles = {
|
||||
name: profile
|
||||
for name, profile in profiles.items()
|
||||
if profile.get("type") != "alias" and profile.get("role") != "test"
|
||||
if is_emulator(profile)
|
||||
}
|
||||
(run.public / "api" / "v1" / "emulators").mkdir(parents=True, exist_ok=True)
|
||||
for name, profile in public_profiles.items():
|
||||
|
||||
@@ -6,6 +6,7 @@ import re
|
||||
import urllib.parse
|
||||
|
||||
from model.systemnames import system_name
|
||||
from model.profiles import is_emulator
|
||||
from resolve.cores import resolve_platform_cores
|
||||
from sitegen import markup
|
||||
from sitegen.config import date_line
|
||||
@@ -262,7 +263,7 @@ def generate_cross_reference(
|
||||
``moved`` collects one page per platform with its core table.
|
||||
"""
|
||||
unique = {
|
||||
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)
|
||||
}
|
||||
|
||||
total_cores = len(unique)
|
||||
|
||||
@@ -18,6 +18,7 @@ from core.hashing import file_digest
|
||||
from model import retired as model_retired
|
||||
from model.database import sha1_at
|
||||
from model.dumpcatalog import load_provenance_snapshots
|
||||
from model.profiles import is_emulator
|
||||
from packs.crossref import FileConsumers
|
||||
from acquire.provenance import build_report
|
||||
from sitegen.apiitems import core_index_items, system_index_items
|
||||
@@ -268,7 +269,7 @@ def build_emulator_gap_report(
|
||||
unique_profiles = {
|
||||
k: v
|
||||
for k, v in profiles.items()
|
||||
if v.get("type") != "alias" and v.get("role") != "test"
|
||||
if is_emulator(v)
|
||||
}
|
||||
from resolve.standalone import merged_standalone_set
|
||||
from model.declarations import platform_declarations
|
||||
@@ -399,7 +400,7 @@ def _cross_reference_export_rows(coverages: dict, profiles: dict) -> list[dict]:
|
||||
unique = {
|
||||
key: value
|
||||
for key, value in profiles.items()
|
||||
if value.get("type") != "alias" and value.get("role") != "test"
|
||||
if is_emulator(value)
|
||||
}
|
||||
rows: list[dict] = []
|
||||
for platform_id, coverage in sorted(coverages.items()):
|
||||
|
||||
@@ -13,6 +13,7 @@ from pathlib import Path
|
||||
from core.sizes import size_text
|
||||
from model.collection import manufacturer_slug
|
||||
from model.systemnames import system_name
|
||||
from model.profiles import reads_own_files
|
||||
from packs.crossref import FileConsumers, entry_target, held_copy
|
||||
from resolve.cores import resolve_platform_cores
|
||||
from sitegen import markup
|
||||
@@ -844,7 +845,7 @@ def emulator_romset(profile: dict) -> str:
|
||||
1.38.1 on MAME 0.289), else the version of a MAME build or of a
|
||||
FinalBurn core, whose sets follow its own release.
|
||||
"""
|
||||
if profile.get("type") in ("alias", "launcher") or profile.get("role") == "test":
|
||||
if not reads_own_files(profile):
|
||||
return ""
|
||||
emulator = str(profile.get("emulator", ""))
|
||||
version = str(profile.get("core_version") or "")
|
||||
|
||||
@@ -11,6 +11,7 @@ from dataclasses import dataclass
|
||||
from core.hashing import parse_hash_list
|
||||
from core.sizes import size_text
|
||||
from model.systemnames import system_name
|
||||
from model.profiles import is_emulator
|
||||
from packs.crossref import FileConsumers
|
||||
from sitegen import entries as siteentries, markup, measurements as sitemeasurements
|
||||
from sitegen.cards import ROMSET_FAQ, emulator_file_anchors
|
||||
@@ -500,7 +501,7 @@ def plan_emulator_pages(profiles: dict,
|
||||
``available`` is the test the pages use for a held file."""
|
||||
stems = set()
|
||||
for name, profile in sorted(profiles.items()):
|
||||
if profile.get("type") == "alias" or profile.get("role") == "test":
|
||||
if not is_emulator(profile):
|
||||
continue
|
||||
files = profile.get("files") or []
|
||||
anchors = emulator_file_anchors(files)
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from model.profiles import unique_emulator_profiles
|
||||
from model.profiles import is_emulator, unique_emulator_profiles
|
||||
from sitegen.emulatorcards import named_system_link
|
||||
|
||||
|
||||
@@ -77,7 +77,7 @@ def emulator_initial(display: str) -> str:
|
||||
def generate_emulators_index(profiles: dict) -> str:
|
||||
unique = {
|
||||
k: v for k, v in profiles.items()
|
||||
if v.get("type") != "alias" and v.get("role") != "test"
|
||||
if is_emulator(v)
|
||||
}
|
||||
aliases = {k: v for k, v in profiles.items() if v.get("type") == "alias"}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import re
|
||||
from dataclasses import dataclass
|
||||
|
||||
from model.platforms import native_layer
|
||||
from model.profiles import is_emulator
|
||||
from resolve.cores import resolve_platform_cores
|
||||
from resolve.nativemode import check_label
|
||||
from sitegen import markup, wanted as sitewanted
|
||||
@@ -517,7 +518,7 @@ def _emulator_platforms(profiles: dict, coverages: dict) -> dict[str, set[str]]:
|
||||
unique_profiles = {
|
||||
k: v
|
||||
for k, v in profiles.items()
|
||||
if v.get("type") != "alias" and v.get("role") != "test"
|
||||
if is_emulator(v)
|
||||
}
|
||||
for pname in coverages:
|
||||
config = coverages[pname]["config"]
|
||||
|
||||
@@ -14,6 +14,7 @@ from model import siteinputs
|
||||
from model.guides import GUIDES, TERMINALS, install_command
|
||||
from model.platforms import load_platform_config
|
||||
from model.registry import list_release_pack_platforms
|
||||
from model.profiles import reads_own_files
|
||||
from resolve.layout import runs_standalone
|
||||
from sitegen import markup
|
||||
from core.paths import REPO_ROOT
|
||||
@@ -134,7 +135,7 @@ def emulator_install_route(name: str, profile: dict) -> tuple[str, list[str], tu
|
||||
the systems both run on: RetroArch's list names AetherSX2, and the
|
||||
command filled RetroArch's system folder, which the app never reads.
|
||||
"""
|
||||
if profile.get("type") in ("alias", "launcher") or profile.get("role") == "test":
|
||||
if not reads_own_files(profile):
|
||||
return "", [], ()
|
||||
if not [f for f in profile.get("files") or [] if isinstance(f, dict) and not comes_with_app(f)]:
|
||||
return "", [], ()
|
||||
|
||||
@@ -14,6 +14,7 @@ from model import siteinputs
|
||||
from model.collection import manufacturer_slug
|
||||
from model.registry import load_versions
|
||||
from model.systemnames import system_name
|
||||
from model.profiles import is_emulator
|
||||
from packs.crossref import FileConsumers
|
||||
from sitegen.cards import PROVENANCE_LABELS, emulator_card_anchor, emulator_file_anchors
|
||||
from sitegen.config import SITE_URL
|
||||
@@ -180,7 +181,7 @@ def _data_member_owners(profiles: dict) -> dict[str, str]:
|
||||
"""
|
||||
owners: dict[str, str] = {}
|
||||
for name in sorted(profiles):
|
||||
if profiles[name].get("type") == "alias" or profiles[name].get("role") == "test":
|
||||
if not is_emulator(profiles[name]):
|
||||
continue
|
||||
for tree in page_data_directories(name, profiles):
|
||||
owners.setdefault(str(tree.get("ref", "")), name)
|
||||
@@ -401,7 +402,7 @@ def _emulator_lookup_records(profiles: dict) -> list[dict]:
|
||||
"""A profile's declared values, each leading to the entry's card."""
|
||||
records: list[dict] = []
|
||||
for key, profile in sorted(profiles.items()):
|
||||
if profile.get("type") == "alias" or profile.get("role") == "test":
|
||||
if not is_emulator(profile):
|
||||
continue
|
||||
entries = profile.get("files") or []
|
||||
own_systems = [str(s) for s in profile.get("systems") or []]
|
||||
|
||||
@@ -11,7 +11,7 @@ import urllib.parse
|
||||
from model import siteinputs
|
||||
from model.collection import profiles_in, profiles_on_disk
|
||||
from model.database import load_database, sha1_at
|
||||
from model.profiles import upstream_profile_index
|
||||
from model.profiles import is_emulator, upstream_profile_index
|
||||
from model.systemnames import system_name
|
||||
from sitegen import entries as siteentries, markup
|
||||
from sitegen.cards import SHORT_HASH
|
||||
@@ -76,7 +76,7 @@ def emulator_named_link(key: str, prefix: str = "") -> str:
|
||||
profile with no page (an alias, a test) is named only."""
|
||||
profile = profiles_on_disk().get(key, {})
|
||||
label = escape_tags(str(profile.get("emulator") or key))
|
||||
if profile.get("type") == "alias" or profile.get("role") == "test":
|
||||
if not is_emulator(profile):
|
||||
return label
|
||||
return f"[{label}]({prefix}emulators/{key}.md)"
|
||||
|
||||
@@ -589,7 +589,7 @@ def _profiles_with_page(emulators_dir: str) -> frozenset[str]:
|
||||
"""The profiles the site writes a page for: no alias, no test core."""
|
||||
profiles = profiles_in(emulators_dir, skip_aliases=True)
|
||||
return frozenset(
|
||||
k for k, v in profiles.items() if v.get("type") != "alias" and v.get("role") != "test"
|
||||
k for k, v in profiles.items() if is_emulator(v)
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ from __future__ import annotations
|
||||
|
||||
from model.collection import SECTION_LABELS, profiles_on_disk, manufacturer_slug
|
||||
from model.composition import GAME_DATA_TOPS
|
||||
from model.profiles import is_emulator
|
||||
from sitegen import starlight as sitestarlight
|
||||
from sitegen.render import count_text, console_href
|
||||
from sitegen.startwith import section_label
|
||||
@@ -114,11 +115,11 @@ def folder_emulator(folder: str) -> tuple[str, str]:
|
||||
named after, by its profile key or its name, else the folder and "".
|
||||
"""
|
||||
profiles = profiles_on_disk()
|
||||
if folder in profiles and profiles[folder].get("type") != "alias" and profiles[folder].get("role") != "test":
|
||||
if folder in profiles and is_emulator(profiles[folder]):
|
||||
return str(profiles[folder].get("emulator") or folder), folder
|
||||
for key in sorted(profiles):
|
||||
profile = profiles[key]
|
||||
if profile.get("type") == "alias" or profile.get("role") == "test":
|
||||
if not is_emulator(profile):
|
||||
continue
|
||||
names = {str(profile.get(field) or "").casefold() for field in ("emulator", "display_name")}
|
||||
if folder.casefold() in names:
|
||||
|
||||
Reference in new issue
Block a user