fix: give an alias the region of its file

This commit is contained in:
Abdessamad Derraz committed 2026-10-18 20:34:20 +02:00
1 parent 2804665b6c
commit ac58bf68d4
2 files changed
+17 -1

No files matched your search

+5 -1
View File
@@ -184,8 +184,12 @@ def build_region_index(profiles: dict) -> dict[str, dict]:
# sees the union and is never dropped on ambiguity. The standalone
# layout is a path of its own: GC/EUR/IPL.bin fell through to the
# bare name and its five-region union, and was never reduced.
# An alias is another name the core reads for the same file:
# scph5552.bin, the name beetle_psx also opens for its European
# BIOS, stayed in a --region jp pack once scph5502.bin went.
aliases = {str(a) for a in f.get("aliases") or []}
priority = f.get("priority")
for key in {path, f.get("standalone_path") or "", name} - {""}:
for key in {path, f.get("standalone_path") or "", name, *aliases} - {""}:
entry = index.setdefault(
key,
{"regions": set(), "has_untagged": False, "emulators": [],
+12
View File
@@ -264,6 +264,18 @@ class TestStandaloneLayoutIsIndexed(unittest.TestCase):
self.assertEqual(region.lookup_regions(index, "GC/EUR/IPL.bin", "IPL.bin"), {"europe"})
self.assertIn("GC/EUR/IPL.bin", slot.build_slot_index(profiles))
def test_an_alias_carries_the_region_of_its_file(self):
"""scph5552.bin, the name beetle_psx also opens for its European
BIOS, stayed in a --region jp pack once scph5502.bin went."""
index = region.build_region_index({"beetle_psx": {"files": [
{"name": "scph5502.bin", "aliases": ["scph5552.bin"],
"region": ["europe", "oceania"]},
]}})
self.assertEqual(
region.lookup_regions(index, "scph5552.bin", "scph5552.bin"),
{"europe", "oceania"},
)
class TestResolveRegionDrops(unittest.TestCase):
def setUp(self):