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.
This commit is contained in:
Abdessamad Derraz committed 2026-10-20 22:38:32 +02:00
1 parent c3af859621
commit 6d38e597db
2 files changed
+17 -4

No files matched your search

+7 -4
View File
@@ -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."""
+10
View File
@@ -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"