From 3e49c5bbdbadf233ce69b7d246d55da6892fa145 Mon Sep 17 00:00:00 2001 From: snake-biscuits <36507175+snake-biscuits@users.noreply.github.com> Date: Mon, 2 Sep 2024 07:14:11 +0100 Subject: [PATCH] (archives.nexon)(#198) closing notes on `PakFile` --- bsp_tool/archives/nexon.py | 1 + tests/archives/nexon/test_PakFile.py | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/bsp_tool/archives/nexon.py b/bsp_tool/archives/nexon.py index 1d1b2324..6c7a1092 100644 --- a/bsp_tool/archives/nexon.py +++ b/bsp_tool/archives/nexon.py @@ -197,6 +197,7 @@ def from_stream(cls, stream: io.BytesIO) -> PakFile: return out def as_bytes(self): + # NOTE: decompresses all data out = list() # TODO: preserve local_files order (if unedited) for local_file in self.local_files.values(): diff --git a/tests/archives/nexon/test_PakFile.py b/tests/archives/nexon/test_PakFile.py index 7284d188..d23fd482 100644 --- a/tests/archives/nexon/test_PakFile.py +++ b/tests/archives/nexon/test_PakFile.py @@ -9,8 +9,7 @@ pakfiles = { "empty": b"".join([ # just an EOCD b"CS\x05\x06", b"\x00" * 16, b"\x01", b"\x00" * 4]), - # TODO: with a file - "deflate": b"".join([ + "deflate": b"".join([ # 1 file, uncompressed # LocalFile b"CS\x03\x04", b"\x00\x00", # unused @@ -38,11 +37,13 @@ b"\x01\x00\x00\x00", # one b"\x00"]) # unused # TODO: with an LZMA compressed file + # NOTE: .as_bytes() cannot recompress yet, test will fail } @pytest.mark.parametrize("raw_pakfile", pakfiles.values(), ids=pakfiles.keys()) def test_from_bytes(raw_pakfile: bytes): + # NOTE: also tests as_bytes pakfile = nexon.PakFile.from_bytes(raw_pakfile) pakfile_bytes = pakfile.as_bytes() # TODO: validate LocalFile.crc32