refactor: read an entry's target as a function

The emulator card read entry_target from the consumers object, which the tests stand in for with a namespace. It is a module function now, and the pairing test resolves an archive member through it as the site does.
This commit is contained in:
Abdessamad Derraz committed 2026-11-05 20:33:37 +01:00
1 parent add6619730
commit 213b20e2c8
3 files changed
+23 -21

No files matched your search

+15 -15
View File
@@ -546,20 +546,6 @@ class FileConsumers:
if member is not entry
}
@staticmethod
def entry_target(entry: dict, files: list[dict]) -> tuple[dict, str]:
"""The entry a profile entry resolves through, and its destination.
A ROM read inside an archive is the archive: FBNeo opens sm1.sm1 in
neogeo.zip, and resolved by its crc32 it credited a loose copy FBNeo
never opens, while no neogeo.zip card named FBNeo. The archive
members the profile reads decide between same-named copies, as in
the emulator pack and verify.
"""
if entry.get("archive"):
return archive_entry(entry["archive"], files), ""
return with_archive_members(entry, files), entry.get("path") or ""
def add_emulators(self, profiles: dict[str, dict]) -> None:
"""Each file a profile entry resolves to, a directory's members included.
@@ -588,13 +574,27 @@ class FileConsumers:
for dest, sha1 in members.items()
]
else:
found = [self.sha1_of(*self.entry_target(entry, files), owner=name)]
found = [self.sha1_of(*entry_target(entry, files), owner=name)]
for sha1 in found:
if sha1:
self.emulators.setdefault(sha1, set()).add(name)
self.emulator_entries.setdefault(sha1, {}).setdefault(name, index)
def entry_target(entry: dict, files: list[dict]) -> tuple[dict, str]:
"""The entry a profile entry resolves through, and its destination.
A ROM read inside an archive is the archive: FBNeo opens sm1.sm1 in
neogeo.zip, and resolved by its crc32 it credited a loose copy FBNeo
never opens, while no neogeo.zip card named FBNeo. The archive
members the profile reads decide between same-named copies, as in
the emulator pack and verify.
"""
if entry.get("archive"):
return archive_entry(entry["archive"], files), ""
return with_archive_members(entry, files), entry.get("path") or ""
def entry_source(f: dict, index: dict) -> str | None:
"""Where the collection holds a profile entry, or None.