From 6d38e597dbed25c033445ee79856d271623aa167 Mon Sep 17 00:00:00 2001 From: Abdessamad Derraz <3028866+Abdess@users.noreply.github.com> Date: Tue, 20 Oct 2026 22:38:32 +0200 Subject: [PATCH] fix: keep a RetroPie list's comma before its and quasi88 writes its list "N88KNJ2.ROM, and N88SUB.ROM". Extended with N88EXT0.ROM, which QUASI88kai reads, it came back as "N88SUB.ROM and N88EXT0.ROM": every list was rewritten in one idiom. A list that puts a comma before its final and keeps it. --- scripts/exporter/retropie_exporter.py | 11 +++++++---- tests/test_export_counts.py | 10 ++++++++++ 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/scripts/exporter/retropie_exporter.py b/scripts/exporter/retropie_exporter.py index de622019..1f2bc27a 100644 --- a/scripts/exporter/retropie_exporter.py +++ b/scripts/exporter/retropie_exporter.py @@ -250,11 +250,13 @@ class Exporter(BaseExporter): return core in required_by @staticmethod - def _join(names: list[str]) -> str: - """RetroPie's own idiom: a, b and c.""" + def _join(names: list[str], serial: bool = False) -> str: + """RetroPie's own idiom: a, b and c, or a, b, and c where the + sentence already writes the comma before its final and.""" if len(names) == 1: return names[0] - return ", ".join(names[:-1]) + " and " + names[-1] + last = ", and " if serial and len(names) > 2 else " and " + return ", ".join(names[:-1]) + last + names[-1] @classmethod def _extended( @@ -269,7 +271,8 @@ class Exporter(BaseExporter): name: appending ", c and d" after "a and b" read "a and b, c and d". """ start, end, written = enumeration - return help_text[:start] + cls._join([*written, *missing]) + help_text[end:] + serial = ", and " in help_text[start:end] + return help_text[:start] + cls._join([*written, *missing], serial) + help_text[end:] def modules(self, originals: dict[str, str]) -> dict[str, tuple[str, str]]: """Module id and help string of every script that mentions BIOS.""" diff --git a/tests/test_export_counts.py b/tests/test_export_counts.py index 03f9880e..740f9778 100644 --- a/tests/test_export_counts.py +++ b/tests/test_export_counts.py @@ -700,6 +700,16 @@ class RetroPieProposals(unittest.TestCase): self.assertIn("gexpress.pce", text) self.assertNotIn("pac-n1.bin", text) + def test_an_extended_list_keeps_its_own_final_comma(self): + """quasi88 writes "N88KNJ2.ROM, and N88SUB.ROM": the list came back + without its comma before the final and.""" + help_text = "Copy bios files A.ROM, B.ROM, and C.ROM to $biosdir/pc88" + enumeration = RetroPie._enumeration(help_text) + self.assertEqual( + RetroPie._extended(help_text, enumeration, ["D.ROM"]), + "Copy bios files A.ROM, B.ROM, C.ROM, and D.ROM to $biosdir/pc88", + ) + def test_a_list_of_alternatives_is_not_extended(self): alternatives = "Copy the required BIOS file a.rom or b.rom to $biosdir" enumeration = "Copy the required BIOS files a.rom and b.rom to $biosdir"