Skip to content

Commit

Permalink
Simplify logic in open reproducible gzip
Browse files Browse the repository at this point in the history
  • Loading branch information
rhpvorderman committed Jan 17, 2024
1 parent c6bba8e commit db36947
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions src/xopen/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1098,14 +1098,12 @@ def _open_reproducible_gzip(filename, mode: str, compresslevel: int):
mode=mode,
mtime=0,
)
gzip_file = None
if igzip is not None and (compresslevel in (1, 2) or "r" in mode):
gzip_file = igzip.IGzipFile(**kwargs, compresslevel=compresslevel)
elif gzip_ng is not None:
# Compression level should be at least 2 for zlib-ng to prevent very big files.
gzip_file = gzip_ng.GzipNGFile(**kwargs, compresslevel=max(compresslevel, 2))

if gzip_file is None:
else:
gzip_file = gzip.GzipFile(**kwargs, compresslevel=compresslevel) # type: ignore
# When (I)GzipFile is created with a fileobj instead of a filename,
# the passed file object is not closed when (I)GzipFile.close()
Expand Down

0 comments on commit db36947

Please sign in to comment.