Source code for scfile.formats.ms3d.io
"""
Extensions for MS3D file format with custom struct-based I/O methods.
"""
from scfile.core import StructIO
from scfile.enums import F
from .exceptions import Ms3dCountsLimit
[docs]
class Ms3dFileIO(StructIO):
def _writecount(self, type: str, count: int, limit: int) -> None:
if count > limit:
raise Ms3dCountsLimit(type, count, limit)
self._writeb(F.U16, count)
def _writefixedstring(self, text: str) -> None:
self.write(text.encode("utf-8").ljust(32, b"\x00"))