From 80575f875ab896953c12437c10b81e95112e1430 Mon Sep 17 00:00:00 2001 From: Marcus Kertesz Date: Thu, 19 Oct 2023 13:44:05 -0700 Subject: [PATCH] Apply black --- src/relic/sga/v2/serialization.py | 24 ++++++++++++------------ tests/test_cli.py | 2 +- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/relic/sga/v2/serialization.py b/src/relic/sga/v2/serialization.py index 085cd4f..af1b6bb 100644 --- a/src/relic/sga/v2/serialization.py +++ b/src/relic/sga/v2/serialization.py @@ -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( @@ -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, @@ -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: @@ -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 @@ -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: @@ -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) @@ -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, diff --git a/tests/test_cli.py b/tests/test_cli.py index f75f64c..61b7fc6 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -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: