refactor: make writable an instance method

This commit is contained in:
Abdessamad Derraz committed 2026-11-17 09:48:13 +01:00
1 parent bc50106587
commit 81a94fc267
7 files changed
+31 -15

No files matched your search

+2 -3
View File
@@ -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:
+3 -1
View File
@@ -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:
+1 -2
View File
@@ -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
+1 -2
View File
@@ -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
+1 -2
View File
@@ -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.