Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor simplifications for the IO code #1885

Merged
merged 1 commit into from May 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/metpy/io/_tools.py
Expand Up @@ -343,7 +343,7 @@ def zlib_decompress_all_frames(data):
while data:
decomp = zlib.decompressobj()
try:
frames.extend(decomp.decompress(data))
frames += decomp.decompress(data)
data = decomp.unused_data
log.debug('Decompressed zlib frame. %d bytes remain.', len(data))
except zlib.error:
Expand Down
5 changes: 2 additions & 3 deletions src/metpy/io/nexrad.py
Expand Up @@ -60,11 +60,10 @@ def bzip_blocks_decompress_all(data):
frames = bytearray()
offset = 0
while offset < len(data):
size_bytes = data[offset:offset + 4]
block_cmp_bytes = abs(int.from_bytes(data[offset:offset + 4], 'big', signed=True))
offset += 4
block_cmp_bytes = abs(Struct('>l').unpack(size_bytes)[0])
try:
frames.extend(bz2.decompress(data[offset:offset + block_cmp_bytes]))
frames += bz2.decompress(data[offset:offset + block_cmp_bytes])
offset += block_cmp_bytes
except OSError:
# If we've decompressed any frames, this is an error mid-stream, so warn, stop
Expand Down