From 11b679252bdd6b500597f9ff85da9d8d5715d5e4 Mon Sep 17 00:00:00 2001 From: Abdessamad Derraz <3028866+Abdess@users.noreply.github.com> Date: Sat, 17 Oct 2026 01:49:34 +0200 Subject: [PATCH] fix: list only real systems as region fallbacks --- scripts/packreadme.py | 10 +++++++++- scripts/region.py | 6 +++++- tests/test_region.py | 16 ++++++++++++++++ 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/scripts/packreadme.py b/scripts/packreadme.py index 6db6c8e1..b64c1c6c 100644 --- a/scripts/packreadme.py +++ b/scripts/packreadme.py @@ -254,7 +254,7 @@ def _build_readme( " Only the best-matching BIOS was kept for each system.\n" ) if fallback_systems: - listed = "\n".join(f" {s}" for s in fallback_systems) + listed = "\n".join(f" {_group_label(s)}" for s in fallback_systems) region_info += ( "\n These systems have no BIOS in those regions, so all\n" " of theirs were kept:\n" @@ -324,3 +324,11 @@ def _build_agnostic_rename_readme( lines.append("") lines.append(f"To use a different variant, rename it to: {destination}") return "\n".join(lines) + "\n" + + +def _group_label(group_id: str) -> str: + """A region group as a reader names it: the system, or one core's slot.""" + emulator, kind, rest = (group_id.split(":", 2) + ["", ""])[:3] + if kind == "variant" and rest: + return f"{rest} ({emulator})" + return group_id diff --git a/scripts/region.py b/scripts/region.py index 9ae04912..06cc0800 100644 --- a/scripts/region.py +++ b/scripts/region.py @@ -323,12 +323,16 @@ def fallback_groups( A world file, or one that declares no region at all, answers every region: the C64 kernal VICE loads by default is untagged, and a group holding it beside a Japanese and a Swedish kernal does have a BIOS for - North America. + North America. A file no system claims is a group of its own and keeps + nothing as a fallback: Dolphin's GC/EUR/IPL.bin named the GameCube as + lacking a North American BIOS the pack carries. """ if not requested: return [] out: list[str] = [] for group_id, members in groups.items(): + if ":file:" in group_id: + continue ranked = _competing_ranks(members, index, requested) served = any( not regions or WORLD in regions diff --git a/tests/test_region.py b/tests/test_region.py index 7fdddf7f..41dc283f 100644 --- a/tests/test_region.py +++ b/tests/test_region.py @@ -380,6 +380,22 @@ class TestFallbackGroups(unittest.TestCase): groups = {"fds": [("disksys.rom", "disksys.rom"), ("generic.rom", "generic.rom")]} self.assertEqual(region.fallback_groups(groups, self.index, ["north-america"]), []) + def test_a_file_no_system_claims_is_no_fallback(self): + """Dolphin's GC/EUR/IPL.bin, alone in its group, named the GameCube + in the pack README as lacking a North American BIOS it carries.""" + groups = {"Dolphin:file:GC/EUR/IPL.bin": [("GC/EUR/IPL.bin", "IPL.bin")], + "fds": [("disksys.rom", "disksys.rom")]} + self.assertEqual( + region.fallback_groups(groups, self.index, ["north-america"]), ["fds"] + ) + + def test_the_readme_names_a_slot_as_a_reader_does(self): + sys.path.insert(0, str(Path(__file__).resolve().parents[1] / "scripts")) + from packreadme import _group_label + + self.assertEqual(_group_label("PicoDrive:variant:megacd"), "megacd (PicoDrive)") + self.assertEqual(_group_label("sega-mega-cd"), "sega-mega-cd") + def test_no_requested_regions_reports_nothing(self): groups = {"fds": [("disksys.rom", "disksys.rom")]} self.assertEqual(region.fallback_groups(groups, self.index, []), [])