fix: count systems once per normalized id

This commit is contained in:
Abdessamad Derraz committed 2026-10-18 16:11:13 +02:00
1 parent cdeed8a523
commit 4f42c52a7f
5 files changed
+42 -23

No files matched your search

+16 -12
View File
@@ -2459,25 +2459,29 @@ def list_emulator_profiles(emulators_dir: str, skip_aliases: bool = True) -> Non
print(f" {name:30s} {display:40s} [{ptype}] {systems}{more}")
def list_system_ids(emulators_dir: str) -> None:
"""Print available system IDs with emulator count.
def system_index(profiles: dict) -> dict[str, tuple[str, set[str]]]:
"""Normalized system id -> (the first spelling met, the emulators).
Counted on the normalized id, as --system selects: listed per spelling,
3do showed two emulators and panasonic-3do six for one system.
One system per normalized id, as --system selects: counted per spelling,
nes and nintendo-nes were two systems and the README announced 550
where --list-systems printed 513.
"""
profiles = load_emulator_profiles(emulators_dir)
system_emus: dict[str, set[str]] = {}
spelling: dict[str, str] = {}
index: dict[str, tuple[str, set[str]]] = {}
for name, p in sorted(profiles.items()):
if p.get("type") in ("alias", "test", "launcher"):
continue
for sys_id in p.get("systems", []):
key = _norm_system_id(sys_id)
system_emus.setdefault(key, set()).add(name)
spelling.setdefault(key, sys_id)
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 ''})")
index.setdefault(key, (sys_id, set()))[1].add(name)
return index
def list_system_ids(emulators_dir: str) -> None:
"""Print available system IDs with emulator count."""
index = system_index(load_emulator_profiles(emulators_dir))
for _key, (spelling, emulators) in sorted(index.items(), key=lambda kv: kv[1][0]):
count = len(emulators)
print(f" {spelling:35s} ({count} emulator{'s' if count > 1 else ''})")
def list_platform_system_ids(platform_name: str, platforms_dir: str) -> None:
+2 -3
View File
@@ -28,6 +28,7 @@ from common import (
load_platform_config,
load_platform_registry,
resolve_platform_cores,
system_index,
unique_emulator_profiles,
write_if_changed,
)
@@ -321,9 +322,7 @@ def generate_readme(db: dict, platforms_dir: str) -> str:
)
acquirable_total = missing_total - unsourceable_total
system_ids: set[str] = set()
for p in profiles.values():
system_ids.update(p.get("systems", []))
system_ids = system_index(profiles)
lines = [
'<p align="center">',
-5
View File
@@ -257,11 +257,6 @@ def generate_home(
cls = "other"
classifications[cls] = classifications.get(cls, 0) + 1
# Count total systems across all profiles
all_systems = set()
for p in unique.values():
all_systems.update(p.get("systems", []))
lines = [
'<div class="rb-hero" markdown>',
"",