fix: write a shared list without a YAML anchor

The amiberry and hatarib extractors give a search record and its copy
record one list object, and PyYAML wrote it as &id001 and *id001.
platforms/retrobat.yml, batocera.yml and knulli.yml carried such
anchors. The platform dumper now writes every list out, and the two
files the RetroBat scrape does not rewrite are dumped again through it:
their content is unchanged.
This commit is contained in:
Abdessamad Derraz committed 2026-11-10 02:25:45 +01:00
1 parent 2eca218535
commit 9c46f7471d
5 files changed
+118 -12

No files matched your search

+45 -5
View File
@@ -6498,7 +6498,7 @@ launchers:
- "tos102{L}.img"
- "tos100{L}.img"
expands:
L: &id001
L:
- us
- uk
- de
@@ -6525,7 +6525,17 @@ launchers:
- "tos162{L}.img"
- "tos106{L}.img"
expands:
L: *id001
L:
- us
- uk
- de
- es
- fr
- it
- nl
- ru
- se
- ''
case_insensitive: false
search_dir: /userdata/bios
passes_to: --machine ste --tos <file>
@@ -6542,7 +6552,17 @@ launchers:
- "tos206{L}.img"
- "tos205{L}.img"
expands:
L: *id001
L:
- us
- uk
- de
- es
- fr
- it
- nl
- ru
- se
- ''
case_insensitive: false
search_dir: /userdata/bios
passes_to: --machine megaste --tos <file>
@@ -6558,7 +6578,17 @@ launchers:
- "etos512{L}.img"
- "tos306{L}.img"
expands:
L: *id001
L:
- us
- uk
- de
- es
- fr
- it
- nl
- ru
- se
- ''
case_insensitive: false
search_dir: /userdata/bios
passes_to: --machine tt --tos <file>
@@ -6576,7 +6606,17 @@ launchers:
- "tos402{L}.img"
- "tos400{L}.img"
expands:
L: *id001
L:
- us
- uk
- de
- es
- fr
- it
- nl
- ru
- se
- ''
case_insensitive: false
search_dir: /userdata/bios
passes_to: --machine falcon --tos <file>
+45 -5
View File
@@ -5349,7 +5349,7 @@ launchers:
- "tos102{L}.img"
- "tos100{L}.img"
expands:
L: &id001
L:
- us
- uk
- de
@@ -5376,7 +5376,17 @@ launchers:
- "tos162{L}.img"
- "tos106{L}.img"
expands:
L: *id001
L:
- us
- uk
- de
- es
- fr
- it
- nl
- ru
- se
- ''
case_insensitive: false
search_dir: /userdata/bios
passes_to: --machine ste --tos <file>
@@ -5393,7 +5403,17 @@ launchers:
- "tos206{L}.img"
- "tos205{L}.img"
expands:
L: *id001
L:
- us
- uk
- de
- es
- fr
- it
- nl
- ru
- se
- ''
case_insensitive: false
search_dir: /userdata/bios
passes_to: --machine megaste --tos <file>
@@ -5409,7 +5429,17 @@ launchers:
- "etos512{L}.img"
- "tos306{L}.img"
expands:
L: *id001
L:
- us
- uk
- de
- es
- fr
- it
- nl
- ru
- se
- ''
case_insensitive: false
search_dir: /userdata/bios
passes_to: --machine tt --tos <file>
@@ -5427,7 +5457,17 @@ launchers:
- "tos402{L}.img"
- "tos400{L}.img"
expands:
L: *id001
L:
- us
- uk
- de
- es
- fr
- it
- nl
- ru
- se
- ''
case_insensitive: false
search_dir: /userdata/bios
passes_to: --machine falcon --tos <file>
+6 -2
View File
@@ -4594,7 +4594,7 @@ launchers:
- emulator: hatarib
build: libretro
kind: core_option
names: &id001
names:
- tos206.img
- tos106.img
- tos104.img
@@ -4609,7 +4609,11 @@ launchers:
- emulator: hatarib
build: libretro
kind: copies
names: *id001
names:
- tos206.img
- tos106.img
- tos104.img
- tos102.img
case_insensitive: true
search_dir: bios/hatari/tos
passes_to: bios/hatarib/<value>
+7
View File
@@ -345,8 +345,15 @@ class _PlatformDumper(yaml.SafeDumper):
Names such as "7800 BIOS (E).rom" or "Bandai - WonderSwan: x" are plain
text, and a bare "01" would be read back as an integer.
Two records sharing one list are written out twice, never as an anchor
and its alias: RetroBat's amiberry search and copy records share their
name list, and the platform file turned into &id001 and *id001.
"""
def ignore_aliases(self, data: object) -> bool:
return True
def _quoted_str(dumper: yaml.SafeDumper, data: str) -> yaml.ScalarNode:
style = None
+15
View File
@@ -1119,5 +1119,20 @@ class EmptyScrapeWritesNothing(unittest.TestCase):
scraper.module_ids(archive)
class PlatformFileHasNoAnchors(unittest.TestCase):
def test_a_shared_list_is_written_twice(self):
"""RetroBat's amiberry search and copy records share one name list:
the platform file read back the same, but held &id001 and *id001."""
import yaml
from scraper.base_scraper import _PlatformDumper
names = ["kick34005.A500", "amiga-os-130.rom"]
text = yaml.dump([{"names": names}, {"names": names}], Dumper=_PlatformDumper)
self.assertNotIn("&id", text)
self.assertNotIn("*id", text)
self.assertEqual(yaml.safe_load(text), [{"names": names}, {"names": names}])
if __name__ == "__main__":
unittest.main()