Skip to content

Commit 01c02a8

Browse files
author
alexander.beedie
committed
expose READ/WRITE gzip consts (in addition to existing FTEXT, FEXTRA, etc)
1 parent 396c1e7 commit 01c02a8

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/isal/igzip.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
READ_BUFFER_SIZE = 128 * 1024
5555

5656
FTEXT, FHCRC, FEXTRA, FNAME, FCOMMENT = 1, 2, 4, 8, 16
57+
READ, WRITE = 1, 2
5758

5859
try:
5960
BadGzipFile = gzip.BadGzipFile # type: ignore
@@ -158,13 +159,13 @@ def __init__(self, filename=None, mode=None,
158159
isal_zlib.ISAL_BEST_SPEED, isal_zlib.ISAL_BEST_COMPRESSION
159160
))
160161
super().__init__(filename, mode, compresslevel, fileobj, mtime)
161-
if self.mode == gzip.WRITE:
162+
if self.mode == WRITE:
162163
self.compress = isal_zlib.compressobj(compresslevel,
163164
isal_zlib.DEFLATED,
164165
-isal_zlib.MAX_WBITS,
165166
isal_zlib.DEF_MEM_LEVEL,
166167
0)
167-
if self.mode == gzip.READ:
168+
if self.mode == READ:
168169
raw = _IGzipReader(self.fileobj)
169170
self._buffer = io.BufferedReader(raw, buffer_size=READ_BUFFER_SIZE)
170171

@@ -197,7 +198,7 @@ def _write_gzip_header(self, compresslevel=_COMPRESS_LEVEL_TRADEOFF):
197198

198199
def write(self, data):
199200
self._check_not_closed()
200-
if self.mode != gzip.WRITE:
201+
if self.mode != WRITE:
201202
import errno
202203
raise OSError(errno.EBADF, "write() on read-only IGzipFile object")
203204

0 commit comments

Comments
 (0)