diff --git a/scripts/exporter/base_exporter.py b/scripts/exporter/base_exporter.py index c3bc14244..756c922d6 100644 --- a/scripts/exporter/base_exporter.py +++ b/scripts/exporter/base_exporter.py @@ -167,8 +167,7 @@ class BaseExporter(ABC, Generic[Content]): list carries.""" return False - @classmethod - def writable(cls, fe: NativeFile, require: str = "") -> bool: + def writable(self, fe: NativeFile, require: str = "") -> bool: """Whether this format can carry the entry. An entry the platform already declares is always carried, hash or @@ -176,7 +175,7 @@ class BaseExporter(ABC, Generic[Content]): hands back a file poorer than the one it corrects. The requirement only gates what we would be adding. """ - return cls._carried(fe, require, cls.SINGLE_HASH_FIELD) + return self._carried(fe, require, self.SINGLE_HASH_FIELD) @classmethod def _carried(cls, fe: NativeFile, require: str, single: str | None) -> bool: diff --git a/scripts/exporter/emudeck_exporter.py b/scripts/exporter/emudeck_exporter.py index d54505a26..47f7a9621 100644 --- a/scripts/exporter/emudeck_exporter.py +++ b/scripts/exporter/emudeck_exporter.py @@ -135,7 +135,9 @@ class Exporter(BaseExporter[str]): if system.native_id != system_id: continue for fe in system.files: - if not cls.writable(fe): + # The base writable rule, which EmuDeck keeps: it needs no + # render state, so the class answers it. + if not cls._carried(fe, "", cls.SINGLE_HASH_FIELD): continue for value in cls._entry_md5s(fe): if _MD5.match(value) and value not in seen: diff --git a/scripts/exporter/recalbox_exporter.py b/scripts/exporter/recalbox_exporter.py index 69e307c58..210894150 100644 --- a/scripts/exporter/recalbox_exporter.py +++ b/scripts/exporter/recalbox_exporter.py @@ -318,8 +318,7 @@ class Exporter(BaseExporter[str]): for label in sorted(getattr(self, "_held_whole", {}).values()) ] - @classmethod - def writable(cls, fe: NativeFile, require: str = "") -> bool: + def writable(self, fe: NativeFile, require: str = "") -> bool: """es_bios.xsd makes md5 and core required: without them, no element. An entry Recalbox already ships has both, so this only ever gates diff --git a/scripts/exporter/retrodeck_exporter.py b/scripts/exporter/retrodeck_exporter.py index 075c4e6c4..328920cf1 100644 --- a/scripts/exporter/retrodeck_exporter.py +++ b/scripts/exporter/retrodeck_exporter.py @@ -83,8 +83,7 @@ class Exporter(BaseExporter[str]): # one from BIOS data alone would throw the component away. return True - @classmethod - def writable(cls, fe: NativeFile, require: str = "") -> bool: + def writable(self, fe: NativeFile, require: str = "") -> bool: """An addition lands only in a manifest it can be placed in.""" if fe.platform is None and not fe.native("component", ""): return False diff --git a/scripts/exporter/systemdat_exporter.py b/scripts/exporter/systemdat_exporter.py index 3d4b1ac17..6e54f79a7 100644 --- a/scripts/exporter/systemdat_exporter.py +++ b/scripts/exporter/systemdat_exporter.py @@ -114,8 +114,7 @@ class Exporter(BaseExporter[str]): def native_sources() -> dict[str, str]: return {"System.dat": SOURCE_URL} - @classmethod - def writable(cls, fe: NativeFile, require: str = "") -> bool: + def writable(self, fe: NativeFile, require: str = "") -> bool: """A clrmamepro rom line is a hash record, and the DAT has no other. The original never states a rom it cannot hash, so neither do we. diff --git a/tests/test_export_counts.py b/tests/test_export_counts.py index 3f78e2e68..b39ee258d 100644 --- a/tests/test_export_counts.py +++ b/tests/test_export_counts.py @@ -145,7 +145,7 @@ class RetroDeckWritesWhatItCounts(unittest.TestCase): written = json.loads(produced["duckstation/component_manifest.json"]) names = [e["filename"] for e in written["duckstation"]["bios"]] self.assertIn("b.bin", names) - self.assertFalse(RetroDeck.writable(spread.files[2])) + self.assertFalse(RetroDeck().writable(spread.files[2])) class HashesTheFormatCannotHold(unittest.TestCase): @@ -434,8 +434,8 @@ class OneMd5FormatsAddWhole(unittest.TestCase): several = NativeFile("boot.bin", "boot.bin", "dc", truth={"md5": [A, B, C]}) single = NativeFile("boot2.bin", "boot2.bin", "dc", truth={"md5": A}) - self.assertFalse(RetroBat.writable(several)) - self.assertTrue(RetroBat.writable(single)) + self.assertFalse(RetroBat().writable(several)) + self.assertTrue(RetroBat().writable(single)) class BizHawkKeepsItsOwnHashes(unittest.TestCase): diff --git a/tests/test_exporters.py b/tests/test_exporters.py index 4bb1cc614..306babfad 100644 --- a/tests/test_exporters.py +++ b/tests/test_exporters.py @@ -558,7 +558,7 @@ class Reconciliation(unittest.TestCase): } systems, _ = build_native_model({"systems": {}}, scraped) entry = systems["nds"].files[0] - self.assertTrue(BaseExporter.writable(entry, require="md5")) + self.assertTrue(_BaseRule().writable(entry, require="md5")) def test_no_format_drops_what_the_platform_already_declares(self): """An export poorer than the file it corrects is not usable.""" @@ -579,7 +579,25 @@ class Reconciliation(unittest.TestCase): } systems, _ = build_native_model(truth, None) entry = systems["nintendo-ds"].files[0] - self.assertFalse(BaseExporter.writable(entry, require="md5")) + self.assertFalse(_BaseRule().writable(entry, require="md5")) + + +class _BaseRule(BaseExporter): + """A concrete exporter that keeps every rule of the base class.""" + + @staticmethod + def platform_name() -> str: + return "base" + + @staticmethod + def native_filename() -> str: + return "base" + + def render(self, systems, report, originals, scraped=None): + return {} + + def validate(self, systems, produced): + return [] class ExporterRegistry(unittest.TestCase):