mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-10-10 13:33:24 -05:00
fix: list systems the way --system selects
This commit is contained in:
1 parent
6207e81d9c
commit
d295e51ad6
2 files changed
+31
-7
No files matched your search
+14
-7
@@ -1709,17 +1709,24 @@ def list_emulator_profiles(emulators_dir: str, skip_aliases: bool = True) -> Non
|
|||||||
|
|
||||||
|
|
||||||
def list_system_ids(emulators_dir: str) -> None:
|
def list_system_ids(emulators_dir: str) -> None:
|
||||||
"""Print available system IDs with emulator count."""
|
"""Print available system IDs with emulator count.
|
||||||
|
|
||||||
|
Counted on the normalized id, as --system selects: listed per spelling,
|
||||||
|
3do showed two emulators and panasonic-3do six for one system.
|
||||||
|
"""
|
||||||
profiles = load_emulator_profiles(emulators_dir)
|
profiles = load_emulator_profiles(emulators_dir)
|
||||||
system_emus: dict[str, list[str]] = {}
|
system_emus: dict[str, set[str]] = {}
|
||||||
for name, p in profiles.items():
|
spelling: dict[str, str] = {}
|
||||||
|
for name, p in sorted(profiles.items()):
|
||||||
if p.get("type") in ("alias", "test", "launcher"):
|
if p.get("type") in ("alias", "test", "launcher"):
|
||||||
continue
|
continue
|
||||||
for sys_id in p.get("systems", []):
|
for sys_id in p.get("systems", []):
|
||||||
system_emus.setdefault(sys_id, []).append(name)
|
key = _norm_system_id(sys_id)
|
||||||
for sys_id in sorted(system_emus):
|
system_emus.setdefault(key, set()).add(name)
|
||||||
count = len(system_emus[sys_id])
|
spelling.setdefault(key, sys_id)
|
||||||
print(f" {sys_id:35s} ({count} emulator{'s' if count > 1 else ''})")
|
for key in sorted(system_emus, key=lambda k: spelling[k]):
|
||||||
|
count = len(system_emus[key])
|
||||||
|
print(f" {spelling[key]:35s} ({count} emulator{'s' if count > 1 else ''})")
|
||||||
|
|
||||||
|
|
||||||
def list_platform_system_ids(platform_name: str, platforms_dir: str) -> None:
|
def list_platform_system_ids(platform_name: str, platforms_dir: str) -> None:
|
||||||
|
|||||||
@@ -40,6 +40,23 @@ class SpellingsAgree(unittest.TestCase):
|
|||||||
self.assertEqual(builder._system_display_name("msxturboR"), builder._system_display_name("msxturbor"))
|
self.assertEqual(builder._system_display_name("msxturboR"), builder._system_display_name("msxturbor"))
|
||||||
|
|
||||||
|
|
||||||
|
class TheListingCountsLikeTheSelection(unittest.TestCase):
|
||||||
|
def test_one_system_is_listed_once_with_every_profile(self):
|
||||||
|
import contextlib # noqa: PLC0415
|
||||||
|
import io # noqa: PLC0415
|
||||||
|
|
||||||
|
out = io.StringIO()
|
||||||
|
with contextlib.redirect_stdout(out):
|
||||||
|
common.list_system_ids(str(REPO_ROOT / "emulators"))
|
||||||
|
lines = {line.split()[0]: line for line in out.getvalue().splitlines() if line.strip()}
|
||||||
|
profiles = common.load_emulator_profiles(str(REPO_ROOT / "emulators"))
|
||||||
|
for spellings in (("3do", "panasonic-3do"), ("atari-2600", "atari_2600")):
|
||||||
|
listed = [s for s in spellings if s in lines]
|
||||||
|
self.assertEqual(len(listed), 1, f"{spellings}: one line per system")
|
||||||
|
count = len(common.profiles_for_systems(profiles, [spellings[0]]))
|
||||||
|
self.assertIn(f"({count} emulator", lines[listed[0]])
|
||||||
|
|
||||||
|
|
||||||
class StandaloneNeedsAStandaloneBuild(unittest.TestCase):
|
class StandaloneNeedsAStandaloneBuild(unittest.TestCase):
|
||||||
def test_a_custom_pack_refuses_it_for_a_libretro_core(self):
|
def test_a_custom_pack_refuses_it_for_a_libretro_core(self):
|
||||||
with tempfile.TemporaryDirectory() as tmp:
|
with tempfile.TemporaryDirectory() as tmp:
|
||||||
|
|||||||
Reference in new issue
Block a user