fix: answer the system names the listing prints

This commit is contained in:
Abdessamad Derraz committed 2026-11-05 12:06:36 +01:00
1 parent 94b5195590
commit da4773a0be
5 files changed
+42 -12

No files matched your search

+1 -1
View File
@@ -16,7 +16,7 @@
# and Invoke-WebRequest throws on a cut transfer before the hash is read: # and Invoke-WebRequest throws on a cut transfer before the hash is read:
# the site's build rewrites this line there (scripts/sitebootstrap.py). # the site's build rewrites this line there (scripts/sitebootstrap.py).
$mismatchAdvice = "The download was most likely cut short: try again. Within minutes of an update of this project the two files can come from caches of different ages. Waiting five minutes settles that." $mismatchAdvice = "The download was most likely cut short: try again. Within minutes of an update of this project the two files can come from caches of different ages. Waiting five minutes settles that."
$defaultInstallSha256 = "f85ee09109492b6586240c75acd179916f570a663bf02ff8b303c019f88d1050" $defaultInstallSha256 = "08be74d479990f072bd16033f258108a583b34baddfd75d9d9be11f23ae77dac"
$maximumInstallerBytes = 2MB $maximumInstallerBytes = 2MB
$installerExit = 0 $installerExit = 0
$installer = if ($PSScriptRoot) { Join-Path $PSScriptRoot "install.py" } else { $null } $installer = if ($PSScriptRoot) { Join-Path $PSScriptRoot "install.py" } else { $null }
+14 -1
View File
@@ -3098,8 +3098,21 @@ def normalize_platform(name: str, say: bool = True) -> str:
print(f" {rule.name} gets the {display_name(rule.manifest)} file list: " print(f" {rule.name} gets the {display_name(rule.manifest)} file list: "
f"--platform {rule.manifest}.") f"--platform {rule.manifest}.")
return rule.manifest return rule.manifest
# --list-platforms prints TrimUI with why it gets no folder, and naming
# it answered "Unknown platform".
for rule in _EMBEDDED_RULES:
if key and not rule.manifest and key == _name_key(rule.name):
refuse_name(name.strip(), f"{rule.name} is not installed to: "
f"{_NO_FOLDER.get(rule.name, 'no source names its BIOS folder')}.",
" Name that folder: --platform retroarch "
"--dest FOLDER")
# Every name --list-platforms prints, so that spruce suggests spruceOS
# and the count is the one the listing shows.
known = list(AVAILABLE_PLATFORMS) + list(dict.fromkeys(
rule.name for rule in _EMBEDDED_RULES
if _name_key(rule.name) not in {_name_key(plat) for plat in AVAILABLE_PLATFORMS}))
refuse_name(name.strip(), f"Unknown platform '{name.strip()}'. " refuse_name(name.strip(), f"Unknown platform '{name.strip()}'. "
+ did_you_mean([name], list(AVAILABLE_PLATFORMS), "--list-platforms")) + did_you_mean([name], known, "--list-platforms"))
def _read_limited_json( def _read_limited_json(
+1 -1
View File
@@ -23,7 +23,7 @@ DEFAULT_INSTALL_URL="https://raw.githubusercontent.com/Abdess/retrobios/main/ins
# curl or wget stop on a cut transfer before the hash is read: the site's # curl or wget stop on a cut transfer before the hash is read: the site's
# build rewrites this line there (scripts/sitebootstrap.py). # build rewrites this line there (scripts/sitebootstrap.py).
MISMATCH_ADVICE="The download was most likely cut short: try again. Within minutes of an update of this project the two files can come from caches of different ages. Waiting five minutes settles that." MISMATCH_ADVICE="The download was most likely cut short: try again. Within minutes of an update of this project the two files can come from caches of different ages. Waiting five minutes settles that."
DEFAULT_INSTALL_SHA256="f85ee09109492b6586240c75acd179916f570a663bf02ff8b303c019f88d1050" DEFAULT_INSTALL_SHA256="08be74d479990f072bd16033f258108a583b34baddfd75d9d9be11f23ae77dac"
MAX_INSTALLER_BYTES=2097152 MAX_INSTALLER_BYTES=2097152
cleanup() { cleanup() {
+8 -8
View File
@@ -27,8 +27,8 @@
{ {
"dest": "roms/ports/retrobios/install.py", "dest": "roms/ports/retrobios/install.py",
"repo_path": "install.py", "repo_path": "install.py",
"size": 1082390, "size": 1083185,
"sha256": "f85ee09109492b6586240c75acd179916f570a663bf02ff8b303c019f88d1050", "sha256": "08be74d479990f072bd16033f258108a583b34baddfd75d9d9be11f23ae77dac",
"executable": false "executable": false
}, },
{ {
@@ -71,8 +71,8 @@
"muos": { "muos": {
"archive": { "archive": {
"dest": "ARCHIVE/RetroBIOS.muxapp", "dest": "ARCHIVE/RetroBIOS.muxapp",
"size": 1136017, "size": 1136812,
"sha256": "9c0587fc18a1402e6f86eeaa8abf7bc26f52bf201e362575adc8e417c983b7de" "sha256": "070626dc9a11addef163495858e5e1ad6808e46522c9570fc4aa2909398b650d"
}, },
"members": [ "members": [
{ {
@@ -92,8 +92,8 @@
{ {
"name": "RetroBIOS/install.py", "name": "RetroBIOS/install.py",
"repo_path": "install.py", "repo_path": "install.py",
"size": 1082390, "size": 1083185,
"sha256": "f85ee09109492b6586240c75acd179916f570a663bf02ff8b303c019f88d1050", "sha256": "08be74d479990f072bd16033f258108a583b34baddfd75d9d9be11f23ae77dac",
"executable": false "executable": false
}, },
{ {
@@ -166,8 +166,8 @@
{ {
"dest": ".config/modules/retrobios/install.py", "dest": ".config/modules/retrobios/install.py",
"repo_path": "install.py", "repo_path": "install.py",
"size": 1082390, "size": 1083185,
"sha256": "f85ee09109492b6586240c75acd179916f570a663bf02ff8b303c019f88d1050", "sha256": "08be74d479990f072bd16033f258108a583b34baddfd75d9d9be11f23ae77dac",
"executable": false "executable": false
}, },
{ {
+18 -1
View File
@@ -4012,8 +4012,25 @@ class ATypoGetsTheClosestName(unittest.TestCase):
self.assertIn(f"--platform {plat}", out.getvalue()) self.assertIn(f"--platform {plat}", out.getvalue())
def test_a_system_that_gets_no_list_is_still_refused(self): def test_a_system_that_gets_no_list_is_still_refused(self):
with contextlib.redirect_stderr(io.StringIO()), self.assertRaises(SystemExit): """TrimUI, which --list-platforms prints, was answered "Unknown
platform" with no way forward."""
err = io.StringIO()
with contextlib.redirect_stderr(err), self.assertRaises(SystemExit):
install.normalize_platform("TrimUI") install.normalize_platform("TrimUI")
self.assertNotIn("Unknown platform", err.getvalue())
self.assertIn("--platform retroarch --dest FOLDER", err.getvalue())
def test_a_system_name_is_suggested(self):
err = io.StringIO()
with contextlib.redirect_stderr(err), self.assertRaises(SystemExit):
install.normalize_platform("spruce")
self.assertIn("Did you mean: spruceOS?", err.getvalue())
# The distinct names --list-platforms prints: Batocera is both a
# platform and a system it recognises.
names = [*install.AVAILABLE_PLATFORMS,
*(line.split(":")[0] for line in install._system_lines())]
listed = len({install._name_key(name) for name in names})
self.assertIn(f"lists all {listed}.", err.getvalue())
def test_a_platform_typo_is_answered_with_one_name(self): def test_a_platform_typo_is_answered_with_one_name(self):
err = io.StringIO() err = io.StringIO()