fix: a Batocera note stays with its own item

Notes were keyed by file path, so a comment before one of the items reading an archive came back before every item reading it: bk's '# MAME' twelve times. A comment after the list's opening bracket matched neither rule and was dropped (enterprise's ep128emu-core). Notes are now keyed by file and archive member, written once, and a head-line comment goes with the first item.
This commit is contained in:
Abdessamad Derraz committed 2026-10-20 01:22:27 +02:00
1 parent e74d182d32
commit cef6d943e2
2 files changed
+47 -17

No files matched your search

+20
View File
@@ -1744,5 +1744,25 @@ class RetroDeckAdditionsFollowTheirCore(unittest.TestCase):
self.assertEqual(read_by_armsx2.native("component", ""), "")
class BatoceraNotesStayWithTheirItem(unittest.TestCase):
"""Keyed by path, bk's '# MAME' came back before each of twelve items
reading bios/bk0010.zip, and enterprise's '"biosFiles": [# ep128emu-core'
was dropped."""
def test_notes_are_kept_once_per_item(self):
from exporter.batocera_exporter import Exporter
lines = [
' "bk": { "name": "BK", "biosFiles": [# head note',
" # MAME",
' { "md5": "a", "file": "bios/bk0010.zip", "zippedFile": "one.rom" },',
' { "md5": "b", "file": "bios/bk0010.zip", "zippedFile": "two.rom" }, # tail',
" ] },",
]
trailing, leading = Exporter._item_notes(lines)
self.assertEqual(leading, {("bios/bk0010.zip", "one.rom"): ["# head note", "# MAME"]})
self.assertEqual(trailing, {("bios/bk0010.zip", "two.rom"): "# tail"})
if __name__ == "__main__":
unittest.main()