mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-26 11:28:51 -06:00
fix: accept core names in profile_sync and audit
This commit is contained in:
1 parent
0107ac8062
commit
fc70a1afa6
4 files changed
+70
-47
No files matched your search
@@ -25,10 +25,11 @@ from pathlib import Path
|
||||
sys.path.insert(0, os.path.dirname(__file__))
|
||||
|
||||
from core import upstream
|
||||
from core.cli import add_repo_inputs, require_directory, suggest_names
|
||||
from core.cli import add_repo_inputs, require_directory
|
||||
from profiling.citations import collect_citations
|
||||
from profiling.repos import select_views
|
||||
from model.sourceref import ref_role, split_source_ref
|
||||
from model.profiles import ProfileSelectionError, load_emulator_profiles, resolve_profile_name
|
||||
from model.safeparse import yaml_load
|
||||
|
||||
# Ways a program asks for somewhere to read from.
|
||||
@@ -123,15 +124,16 @@ def main() -> None:
|
||||
parser.error("name profiles or pass --all, not both")
|
||||
require_directory(args.emulators_dir, "--emulators-dir")
|
||||
|
||||
known = sorted(path.stem for path in Path(args.emulators_dir).glob("*.yml"))
|
||||
unknown = [name for name in args.emulators if name not in known]
|
||||
if unknown:
|
||||
raise SystemExit(
|
||||
"ERROR: unknown profile " + ", ".join(unknown) + ". "
|
||||
+ suggest_names(unknown, known, "python scripts/verify.py --list-emulators")
|
||||
)
|
||||
names = args.emulators
|
||||
profiles = load_emulator_profiles(args.emulators_dir, skip_aliases=False) if args.emulators else {}
|
||||
try:
|
||||
names = [
|
||||
resolve_profile_name(name, profiles, "python scripts/verify.py --list-emulators")
|
||||
for name in args.emulators
|
||||
]
|
||||
except ProfileSelectionError as exc:
|
||||
raise SystemExit(f"ERROR: {exc}") from None
|
||||
if args.all:
|
||||
known = sorted(path.stem for path in Path(args.emulators_dir).glob("*.yml"))
|
||||
names = []
|
||||
for name in known:
|
||||
with open(Path(args.emulators_dir) / f"{name}.yml", encoding="utf-8") as handle:
|
||||
|
||||
+30
-24
@@ -109,6 +109,35 @@ def entry_serves_systems(entry: dict, profile: dict, system_ids: list[str]) -> b
|
||||
return bool(wanted & {norm_system_id(sid) for sid in entry_system_ids(entry, profile)})
|
||||
|
||||
|
||||
def resolve_profile_name(
|
||||
name: str, all_profiles: dict, hint_command: str = "--list-emulators"
|
||||
) -> str:
|
||||
"""The profile a name selects: its own key, else the one profile whose
|
||||
cores: names it.
|
||||
|
||||
A buildbot name (pcfx, advmame) lives in a profile's cores:, and the
|
||||
spelling hints sent pcfx to two PlayStation cores. The hints are drawn
|
||||
from what --list-emulators shows.
|
||||
"""
|
||||
if name in all_profiles:
|
||||
return name
|
||||
claimants = sorted(
|
||||
key for key in upstream_profile_index(all_profiles).get(name, ())
|
||||
if all_profiles[key].get("type") != "launcher" and all_profiles[key].get("role") != "test"
|
||||
)
|
||||
if len(claimants) == 1:
|
||||
return claimants[0]
|
||||
if claimants:
|
||||
raise ProfileSelectionError(
|
||||
f"{name} is a core name of {', '.join(claimants)}: "
|
||||
f"use --emulator with one of them"
|
||||
)
|
||||
available = sorted(key for key, value in all_profiles.items() if is_emulator(value))
|
||||
raise ProfileSelectionError(
|
||||
f"emulator '{name}' not found\n" + suggest_names([name], available, hint_command)
|
||||
)
|
||||
|
||||
|
||||
def select_emulator_profiles(
|
||||
requested: list[str],
|
||||
all_profiles: dict,
|
||||
@@ -124,30 +153,7 @@ def select_emulator_profiles(
|
||||
"""
|
||||
selected: list[tuple[str, dict]] = []
|
||||
for name in requested:
|
||||
if name not in all_profiles:
|
||||
# A buildbot name (pcfx, advmame) lives in a profile's cores:,
|
||||
# and the spelling hints sent pcfx to two PlayStation cores.
|
||||
claimants = sorted(
|
||||
key for key in upstream_profile_index(all_profiles).get(name, ())
|
||||
if all_profiles[key].get("type") != "launcher" and all_profiles[key].get("role") != "test"
|
||||
)
|
||||
if len(claimants) == 1:
|
||||
name = claimants[0]
|
||||
elif claimants:
|
||||
raise ProfileSelectionError(
|
||||
f"{name} is a core name of {', '.join(claimants)}: "
|
||||
f"use --emulator with one of them"
|
||||
)
|
||||
if name not in all_profiles:
|
||||
available = sorted(
|
||||
key
|
||||
for key, value in all_profiles.items()
|
||||
if is_emulator(value)
|
||||
)
|
||||
raise ProfileSelectionError(
|
||||
f"emulator '{name}' not found\n"
|
||||
+ suggest_names([name], available, "--list-emulators")
|
||||
)
|
||||
name = resolve_profile_name(name, all_profiles)
|
||||
profile = all_profiles[name]
|
||||
kind = profile.get("type", "libretro")
|
||||
if kind == "alias":
|
||||
|
||||
+9
-14
@@ -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 is_emulator, load_emulator_profiles
|
||||
from model.profiles import ProfileSelectionError, is_emulator, load_emulator_profiles, resolve_profile_name
|
||||
from core.cli import add_repo_inputs, suggest_names
|
||||
from profiling.bump import DEFAULT_CACHE, write_version
|
||||
from profiling.realign import realign_prose
|
||||
@@ -308,19 +308,14 @@ def select_profiles(profiles: dict, args: argparse.Namespace) -> dict:
|
||||
print(f"the branch {verb} no profile against {base}", file=sys.stderr)
|
||||
return selected
|
||||
if args.emulator:
|
||||
names = [args.emulator] if isinstance(args.emulator, str) else args.emulator
|
||||
unknown = [name for name in names if name not in profiles]
|
||||
if unknown:
|
||||
# Suggested from what the listing it names shows: counted over the
|
||||
# alias and test profiles too, "lists all 553" pointed at 530 lines.
|
||||
listed = sorted(
|
||||
name for name, profile in profiles.items()
|
||||
if is_emulator(profile)
|
||||
)
|
||||
raise SystemExit(
|
||||
f"ERROR: unknown profile {', '.join(unknown)}. "
|
||||
+ suggest_names(unknown, listed, "python scripts/verify.py --list-emulators")
|
||||
)
|
||||
requested = [args.emulator] if isinstance(args.emulator, str) else args.emulator
|
||||
try:
|
||||
names = [
|
||||
resolve_profile_name(name, profiles, "python scripts/verify.py --list-emulators")
|
||||
for name in requested
|
||||
]
|
||||
except ProfileSelectionError as exc:
|
||||
raise SystemExit(f"ERROR: {exc}") from None
|
||||
return {name: profiles[name] for name in dict.fromkeys(names)}
|
||||
|
||||
# --system matches as verify.py --list-systems lists and --system selects:
|
||||
|
||||
Reference in new issue
Block a user