Skip to content

Commit

Permalink
Apply black
Browse files Browse the repository at this point in the history
  • Loading branch information
ModernMAK committed Oct 19, 2023
1 parent fd909ce commit 80575f8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
24 changes: 12 additions & 12 deletions src/relic/sga/v2/serialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def assemble_meta(_: BinaryIO, header: MetaBlock, __: None) -> Dict[str, object]


def disassemble_meta(
_: BinaryIO, metadata: Dict[str, object]
_: BinaryIO, metadata: Dict[str, object]
) -> Tuple[MetaBlock, None]:
"""Converts the archive's metadata dictionary into a MetaBlock class the Serializer can use."""
meta = MetaBlock(
Expand Down Expand Up @@ -197,7 +197,7 @@ def assemble_file(self, parent_dir: FS, file_def: FileDef) -> None:

# Still hate this, but might as well reuse it
_HEADER_SIZE = (
256 + 8
256 + 8
) # 256 string buffer (likely 256 cause 'max path' on windows used to be 256), and 4 byte unk, and 4 byte checksum (crc32)
lazy_data_header = FileLazyInfo(
jump_to=self.ptrs.data_pos + file_def.data_pos - _HEADER_SIZE,
Expand All @@ -213,7 +213,7 @@ def assemble_file(self, parent_dir: FS, file_def: FileDef) -> None:
unpacked_size=file_def.length_on_disk,
stream=self.stream,
decompress=file_def.storage_type
!= StorageType.STORE, # self.decompress_files,
!= StorageType.STORE, # self.decompress_files,
)

def _generate_crc32() -> bytes:
Expand Down Expand Up @@ -242,8 +242,8 @@ def _generate_metadata() -> None:
_set_info(name, modified, crc32)

if (
lazy_data_header.jump_to < 0
or lazy_data_header.jump_to >= lazy_info_decomp.jump_to
lazy_data_header.jump_to < 0
or lazy_data_header.jump_to >= lazy_info_decomp.jump_to
):
# Ignore checksum / name ~ Archive does not have this metadata
# Recalculate it
Expand Down Expand Up @@ -276,7 +276,7 @@ def _generate_metadata() -> None:

class _DisassassemblerV2(FSDisassembler[FileDef]):
_HEADER_SIZE = (
256 + 8
256 + 8
) # 256 string buffer (likely 256 cause 'max path' on windows used to be 256), and 8 byte checksum

def disassemble_file(self, container_fs: FS, file_name: str) -> FileDef:
Expand Down Expand Up @@ -309,12 +309,12 @@ def disassemble_file(self, container_fs: FS, file_name: str) -> FileDef:
)

name_buffer = bytearray(b"\0" * 256)
name_buffer[0: len(file_name)] = file_name.encode("ascii")
name_buffer[0 : len(file_name)] = file_name.encode("ascii")
_name_buffer_pos = _write_data(name_buffer, self.data_stream)
uncompressed_crc = zlib.crc32(data)
# compressed_crc = zlib.crc32(store_data)
if "modified" in metadata and metadata["modified"] != int.from_bytes(
b"UNK\0", "little", signed=False
b"UNK\0", "little", signed=False
): # handle my unknown case ~ UNK\0 resolves to 1970, so I don't think we need to worry about that
timestamp: int = metadata["modified"] # type: ignore
timestamp_buffer = timestamp.to_bytes(4, "little", signed=True)
Expand Down Expand Up @@ -349,10 +349,10 @@ class EssenceFSSerializer(_s.EssenceFSSerializer[FileDef, MetaBlock, None]):
"""

def __init__(
self,
toc_serializer: StreamSerializer[TocBlock],
meta_serializer: StreamSerializer[MetaBlock],
toc_serialization_info: TOCSerializationInfo[FileDef],
self,
toc_serializer: StreamSerializer[TocBlock],
meta_serializer: StreamSerializer[MetaBlock],
toc_serialization_info: TOCSerializationInfo[FileDef],
):
super().__init__(
version=version,
Expand Down
2 changes: 1 addition & 1 deletion tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def test_cli_repack(src: str):
with tempfile.NamedTemporaryFile("w+", delete=False) as config_file:
repacked_file_name = config_file.name

status = cli.run_with("sga", "repack", "v2", src, repacked_file_name)
status = cli.run_with("sga", "repack", "v2", src, repacked_file_name)
assert status == 0
finally:
try:
Expand Down

0 comments on commit 80575f8

Please sign in to comment.