From db36947fa903e6ec859fae2f76d69442a373d634 Mon Sep 17 00:00:00 2001 From: Ruben Vorderman Date: Wed, 17 Jan 2024 09:33:04 +0100 Subject: [PATCH] Simplify logic in open reproducible gzip --- src/xopen/__init__.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/xopen/__init__.py b/src/xopen/__init__.py index 3c6e883..4970301 100644 --- a/src/xopen/__init__.py +++ b/src/xopen/__init__.py @@ -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()