From 10dc9a11acf66c9544221ca229456360ea3fdb32 Mon Sep 17 00:00:00 2001 From: Abdessamad Derraz <3028866+Abdess@users.noreply.github.com> Date: Wed, 21 Oct 2026 10:12:07 +0200 Subject: [PATCH] feat: accept ISO country codes for --region jp, us, kr and gb were aliases but au was unknown, and the first spelling offered for it was auto, which means world. Every territory of the region tree now answers to its ISO 3166-1 code, in the build scripts and in the installer, whose SHA-256 is pinned again. --- install.ps1 | 2 +- install.py | 24 ++++++++++++++++++++++++ install.sh | 2 +- scripts/region.py | 28 +++++++++++++++++++++++++++- tests/test_region.py | 18 ++++++++++++++++++ wiki/advanced-usage.md | 5 +++-- 6 files changed, 74 insertions(+), 5 deletions(-) diff --git a/install.ps1 b/install.ps1 index f67d62ec..5c41787d 100644 --- a/install.ps1 +++ b/install.ps1 @@ -11,7 +11,7 @@ $ErrorActionPreference = "Stop" $defaultInstallUrl = "https://raw.githubusercontent.com/Abdess/retrobios/main/install.py" - $defaultInstallSha256 = "1cf3bd0d3985e3a728513be75cb80682fe1e7a9224da6437e8f1cd9b2a3eedb1" + $defaultInstallSha256 = "3f6f906ede89a0a6c350a1f85f668a213031ec8e84215595cdbd160c22ed3352" $maximumInstallerBytes = 2MB $installerExit = 0 $installer = if ($PSScriptRoot) { Join-Path $PSScriptRoot "install.py" } else { $null } diff --git a/install.py b/install.py index 4e3581a9..249846ce 100644 --- a/install.py +++ b/install.py @@ -138,6 +138,30 @@ REGION_ALIASES: dict[str, str] = { "korea": "south-korea", "auto": WORLD_REGION, "gb": "uk", + "ca": "canada", + "br": "brazil", + "mx": "mexico", + "ar": "argentina", + "fr": "france", + "de": "germany", + "it": "italy", + "es": "spain", + "nl": "netherlands", + "pt": "portugal", + "gr": "greece", + "pl": "poland", + "ru": "russia", + "se": "sweden", + "no": "norway", + "dk": "denmark", + "fi": "finland", + "cn": "china", + "tw": "taiwan", + "hk": "hong-kong", + "sg": "singapore", + "in": "india", + "au": "australia", + "nz": "new-zealand", } AREA_TERRITORIES: dict[str, frozenset] = { "asia-ntsc": frozenset({"taiwan"}), diff --git a/install.sh b/install.sh index c5c3ec4a..199d31e1 100755 --- a/install.sh +++ b/install.sh @@ -18,7 +18,7 @@ esac TEMP_INSTALLER="" TEMP_DIRECTORY="" DEFAULT_INSTALL_URL="https://raw.githubusercontent.com/Abdess/retrobios/main/install.py" -DEFAULT_INSTALL_SHA256="1cf3bd0d3985e3a728513be75cb80682fe1e7a9224da6437e8f1cd9b2a3eedb1" +DEFAULT_INSTALL_SHA256="3f6f906ede89a0a6c350a1f85f668a213031ec8e84215595cdbd160c22ed3352" MAX_INSTALLER_BYTES=2097152 cleanup() { diff --git a/scripts/region.py b/scripts/region.py index a299a8a0..bb7cfaf9 100644 --- a/scripts/region.py +++ b/scripts/region.py @@ -64,7 +64,9 @@ _PARENT: dict[str, str] = { REGIONS: frozenset[str] = frozenset({WORLD} | set(REGION_TREE) | set(_PARENT)) -# Accepted on the CLI and for legacy profile values. +# Accepted on the CLI and for legacy profile values. Every territory also +# answers to its ISO 3166-1 code: `au` alone was unknown, and the closest +# spelling offered first was `auto`, which means world. ALIASES: dict[str, str] = { "jp": "japan", "ntsc-j": "japan", @@ -78,6 +80,30 @@ ALIASES: dict[str, str] = { "korea": "south-korea", "auto": WORLD, "gb": "uk", + "ca": "canada", + "br": "brazil", + "mx": "mexico", + "ar": "argentina", + "fr": "france", + "de": "germany", + "it": "italy", + "es": "spain", + "nl": "netherlands", + "pt": "portugal", + "gr": "greece", + "pl": "poland", + "ru": "russia", + "se": "sweden", + "no": "norway", + "dk": "denmark", + "fi": "finland", + "cn": "china", + "tw": "taiwan", + "hk": "hong-kong", + "sg": "singapore", + "in": "india", + "au": "australia", + "nz": "new-zealand", } diff --git a/tests/test_region.py b/tests/test_region.py index 0068e364..523951a1 100644 --- a/tests/test_region.py +++ b/tests/test_region.py @@ -1048,6 +1048,24 @@ class UnknownRegionSaysWhatToType(unittest.TestCase): self.assertIn("Short forms:", str(caught.exception)) +class CountryCodesNameTheirTerritory(unittest.TestCase): + """`au` was unknown while `jp`, `us`, `kr` and `gb` were aliases, and the + first spelling offered for it was `auto`, which means world.""" + + def test_au_is_australia(self): + self.assertEqual(region.parse_requested("au,jp"), ["australia", "japan"]) + + def test_every_territory_answers_to_a_two_letter_code(self): + areas = set(region.AREA_TERRITORIES) + territories = { + member for members in region.REGION_TREE.values() for member in members + } - areas + coded = { + target for alias, target in region.ALIASES.items() if len(alias) == 2 + } | {slug for slug in territories if len(slug) == 2} + self.assertEqual(territories - coded, set()) + + class GenesisPlusGxUsBiosServesEurope(unittest.TestCase): """sms_cart_region_detect returns REGION_USA for any export header diff --git a/wiki/advanced-usage.md b/wiki/advanced-usage.md index 0379e491..27ad6818 100644 --- a/wiki/advanced-usage.md +++ b/wiki/advanced-usage.md @@ -76,8 +76,9 @@ fall back to Japan. It does not mean "keep all three": when a US BIOS exists for a system, the European and Japanese ones are dropped. Accepted names are territory slugs (`japan`, `north-america`, `europe`, -`south-korea`, `taiwan`, `brazil`, `france`...) plus short aliases (`jp`, `us`, -`eu`, `kr`) and the signal spellings (`ntsc-j`, `ntsc-u`, `pal`). Territories +`south-korea`, `taiwan`, `brazil`, `france`...) plus short aliases (`us`, `eu`, +and the ISO 3166 code of each territory: `jp`, `kr`, `au`, `br`, `fr`...) and +the signal spellings (`ntsc-j`, `ntsc-u`, `pal`). Territories nest, so `--region europe` keeps a BIOS declared `[france]`, and `--region france` keeps one declared `[europe]`.