mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-10-16 16:33:27 -05:00
fix: read exportable through the exporter instance
This commit is contained in:
1 parent
0198445ee4
commit
c6cac0ad1b
3 files changed
+22
-4
No files matched your search
@@ -81,9 +81,8 @@ class BaseExporter(ABC):
|
||||
|
||||
# Shared helpers
|
||||
|
||||
@classmethod
|
||||
def exportable(
|
||||
cls,
|
||||
self,
|
||||
systems: dict[str, NativeSystem],
|
||||
require: str = "",
|
||||
) -> list[tuple[NativeSystem, list[NativeFile]]]:
|
||||
@@ -92,11 +91,12 @@ class BaseExporter(ABC):
|
||||
`require` names a hash the format cannot omit. An entry the format
|
||||
has no way to express is dropped here and counted by the caller,
|
||||
never written as a half entry the platform would read as a file that
|
||||
can never verify.
|
||||
can never verify. Read through the instance: RomM decides on the
|
||||
keys its render has seen.
|
||||
"""
|
||||
result: list[tuple[NativeSystem, list[NativeFile]]] = []
|
||||
for system in systems.values():
|
||||
files = [fe for fe in system.files if fe.name and cls.writable(fe, require)]
|
||||
files = [fe for fe in system.files if fe.name and self.writable(fe, require)]
|
||||
if files:
|
||||
result.append((system, files))
|
||||
return result
|
||||
|
||||
@@ -52,6 +52,12 @@ class Exporter(BaseExporter):
|
||||
def native_sources() -> dict[str, str]:
|
||||
return {"known_bios_files.json": SOURCE_URL}
|
||||
|
||||
def __init__(self) -> None:
|
||||
super().__init__()
|
||||
# Filled by render; empty until then, so writable() answers before it.
|
||||
self._platform_keys: set[tuple[str, str]] = set()
|
||||
self._first_addition: dict[tuple[str, str], int] = {}
|
||||
|
||||
@staticmethod
|
||||
def _verifiable(fe: NativeFile) -> bool:
|
||||
return bool(fe.size()) and any(
|
||||
|
||||
@@ -425,6 +425,18 @@ class RommKeepsItsOwnKeys(unittest.TestCase):
|
||||
self.assertEqual(written["dc:boot.bin"]["size"], "2097152")
|
||||
self.assertFalse(exporter.writable(ours))
|
||||
|
||||
def test_the_shared_helper_reads_every_exporter_the_same_way(self):
|
||||
"""RomM's writable is per instance; the base helper bound fe as self."""
|
||||
from exporter import discover_exporters # noqa: PLC0415
|
||||
|
||||
theirs = NativeFile("boot.bin", "dc/boot.bin", "dc",
|
||||
platform={"size": 2097152, "md5": A, "core": "libretro/flycast"})
|
||||
systems = {"dc": NativeSystem("dc", files=[theirs], from_platform=True)}
|
||||
for name, cls in sorted(discover_exporters().items()):
|
||||
with self.subTest(exporter=name):
|
||||
pairs = cls().exportable(systems)
|
||||
self.assertEqual([fe for _, files in pairs for fe in files], [theirs])
|
||||
|
||||
class NamesInAnotherDirectory(unittest.TestCase):
|
||||
def test_a_truth_path_in_another_directory_does_not_match(self):
|
||||
scraped = {"systems": {"pc98": {"files": [
|
||||
|
||||
Reference in new issue
Block a user