Skip to content

Commit

Permalink
refactor: rename variable to make clear its buffered
Browse files Browse the repository at this point in the history
  • Loading branch information
michalc committed Jul 16, 2023
1 parent 7091b0a commit 3e0d7d0
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions stream_zip.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@
from struct import Struct
import zlib

_NO_COMPRESSION_32 = object()
_NO_COMPRESSION_64 = object()
_NO_COMPRESSION_BUFFERED_32 = object()
_NO_COMPRESSION_BUFFERED_64 = object()
_ZIP_32 = object()
_ZIP_64 = object()

_AUTO_UPGRADE_CENTRAL_DIRECTORY = object()
_NO_AUTO_UPGRADE_CENTRAL_DIRECTORY = object()

def NO_COMPRESSION_32(offset, default_get_compressobj):
return _NO_COMPRESSION_32, _NO_AUTO_UPGRADE_CENTRAL_DIRECTORY, default_get_compressobj, None, None
return _NO_COMPRESSION_BUFFERED_32, _NO_AUTO_UPGRADE_CENTRAL_DIRECTORY, default_get_compressobj, None, None

def NO_COMPRESSION_64(offset, default_get_compressobj):
return _NO_COMPRESSION_64, _NO_AUTO_UPGRADE_CENTRAL_DIRECTORY, default_get_compressobj, None, None
return _NO_COMPRESSION_BUFFERED_64, _NO_AUTO_UPGRADE_CENTRAL_DIRECTORY, default_get_compressobj, None, None

def ZIP_32(offset, default_get_compressobj):
return _ZIP_32, _NO_AUTO_UPGRADE_CENTRAL_DIRECTORY, default_get_compressobj, None, None
Expand Down Expand Up @@ -406,7 +406,7 @@ def _chunks():
data_func = \
_zip_64_local_header_and_data if _method is _ZIP_64 else \
_zip_32_local_header_and_data if _method is _ZIP_32 else \
_no_compression_64_local_header_and_data if _method is _NO_COMPRESSION_64 else \
_no_compression_64_local_header_and_data if _method is _NO_COMPRESSION_BUFFERED_64 else \
_no_compression_32_local_header_and_data

central_directory_header_entry, name_encoded, extra = yield from data_func(name_encoded, mod_at_ms_dos, mod_at_unix_extra, external_attr, uncompressed_size, crc_32, _get_compress_obj, evenly_sized(chunks))
Expand All @@ -416,7 +416,7 @@ def _chunks():
zip_64_central_directory = zip_64_central_directory \
or (_auto_upgrade_central_directory is _AUTO_UPGRADE_CENTRAL_DIRECTORY and offset > 0xffffffff) \
or (_auto_upgrade_central_directory is _AUTO_UPGRADE_CENTRAL_DIRECTORY and len(central_directory) > 0xffff) \
or _method in (_ZIP_64, _NO_COMPRESSION_64)
or _method in (_ZIP_64, _NO_COMPRESSION_BUFFERED_64)

max_central_directory_length, max_central_directory_start_offset, max_central_directory_size = \
(0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff) if zip_64_central_directory else \
Expand Down

0 comments on commit 3e0d7d0

Please sign in to comment.