Skip to content

Commit 16ed953

Browse files
committed
Some linting issues
1 parent af5f788 commit 16ed953

File tree

3 files changed

+20
-23
lines changed

3 files changed

+20
-23
lines changed

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
zip_safe=False,
4646
packages=find_packages('src'),
4747
package_dir={'': 'src'},
48-
package_data = {'isal': ['*.pxd']},
48+
package_data={'isal': ['*.pxd']},
4949
url="https://github.com/rhpvorderman/python-isal",
5050
classifiers=[
5151
"Programming Language :: Python :: 3 :: Only",
@@ -64,7 +64,7 @@
6464
ext_modules=[
6565
Extension("isal.isal_zlib", ["src/isal/isal_zlib.pyx"],
6666
libraries=["isal"], **EXTENSION_OPTS),
67-
Extension("isal._isal", ["src/isal/_isal.pyx"],
67+
Extension("isal._isal", ["src/isal/_isal.pyx"],
6868
libraries=["isal"], **EXTENSION_OPTS),
6969
]
7070
)

src/isal/igzip.py

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -22,33 +22,28 @@
2222
Library to speed up its methods."""
2323

2424
import argparse
25+
import gzip
2526
import io
2627
import os
28+
from gzip import BadGzipFile
29+
2730
import _compression
2831

29-
# We import a copy of the gzip module so we can use that to define the classes
30-
# here and replace the zlib module with the isal_zlib module. This way the
31-
# zlib module will not be replaced for the original zlib module. So IGzipFile
32-
# and gzip.GzipFile can be used in the same code.
33-
# Also this reuses as much code from the stdlib without copying it.
3432
from . import isal_zlib
3533

34+
__all__ = ["BadGzipFile", "IGzipFile", "open", "compress", "decompress"]
35+
3636
_COMPRESS_LEVEL_FAST = isal_zlib.ISAL_BEST_SPEED
3737
_COMPRESS_LEVEL_TRADEOFF = isal_zlib.ISAL_DEFAULT_COMPRESSION
3838
_COMPRESS_LEVEL_BEST = isal_zlib.ISAL_BEST_COMPRESSION
3939
_BLOCK_SIZE = 64*1024
4040

41-
import gzip
42-
from gzip import BadGzipFile
43-
44-
__all__ = ["BadGzipFile", "IGzipFile", "open", "compress", "decompress"]
45-
4641

4742
# The open method was copied from the python source with minor adjustments.
4843
def open(filename, mode="rb", compresslevel=_COMPRESS_LEVEL_TRADEOFF,
4944
encoding=None, errors=None, newline=None):
5045
"""Open a gzip-compressed file in binary or text mode. This uses the isa-l
51-
library for optimised speed.
46+
library for optimized speed.
5247
5348
The filename argument can be an actual filename (a str or bytes object), or
5449
an existing file object to read from or write to.
@@ -71,7 +66,8 @@ def open(filename, mode="rb", compresslevel=_COMPRESS_LEVEL_TRADEOFF,
7166
raise ValueError("Invalid mode: %r" % (mode,))
7267
else:
7368
if encoding is not None:
74-
raise ValueError("Argument 'encoding' not supported in binary mode")
69+
raise ValueError(
70+
"Argument 'encoding' not supported in binary mode")
7571
if errors is not None:
7672
raise ValueError("Argument 'errors' not supported in binary mode")
7773
if newline is not None:
@@ -119,7 +115,7 @@ def __repr__(self):
119115
def flush(self, zlib_mode=isal_zlib.Z_SYNC_FLUSH):
120116
super().flush(zlib_mode)
121117

122-
def write(self,data):
118+
def write(self, data):
123119
self._check_not_closed()
124120
if self.mode != gzip.WRITE:
125121
import errno
@@ -153,15 +149,15 @@ def __init__(self, fp):
153149
super().__init__(fp, isal_zlib.decompressobj,
154150
wbits=16 + isal_zlib.MAX_WBITS)
155151

156-
157152

158153
# Plagiarized from gzip.py from python's stdlib.
159154
def compress(data, compresslevel=_COMPRESS_LEVEL_BEST, *, mtime=None):
160155
"""Compress data in one shot and return the compressed string.
161156
Optional argument is the compression level, in range of 0-3.
162157
"""
163158
buf = io.BytesIO()
164-
with IGzipFile(fileobj=buf, mode='wb', compresslevel=compresslevel, mtime=mtime) as f:
159+
with IGzipFile(fileobj=buf, mode='wb',
160+
compresslevel=compresslevel, mtime=mtime) as f:
165161
f.write(data)
166162
return buf.getvalue()
167163

@@ -220,7 +216,5 @@ def main():
220216
out_file.write(block)
221217

222218

223-
224-
225219
if __name__ == "__main__":
226-
main()
220+
main()

tests/test_isal.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
# Wbits for ZLIB compression, GZIP compression, and RAW compressed streams
4242
WBITS_RANGE = list(range(9, 16)) + list(range(25, 32)) + list(range(-15, -8))
4343

44+
4445
@pytest.mark.parametrize(["data_size", "value"],
4546
itertools.product(DATA_SIZES, SEEDS))
4647
def test_crc32(data_size, value):
@@ -71,8 +72,9 @@ def test_decompress_zlib(data_size, level):
7172
decompressed = isal_zlib.decompress(compressed)
7273
assert decompressed == data
7374

75+
7476
@pytest.mark.parametrize(["data_size", "level", "wbits", "memLevel"],
75-
itertools.product([128* 1024], range(4),
77+
itertools.product([128 * 1024], range(4),
7678
WBITS_RANGE, range(1, 10)))
7779
def test_decompress_wbits(data_size, level, wbits, memLevel):
7880
data = DATA[:data_size]
@@ -81,6 +83,7 @@ def test_decompress_wbits(data_size, level, wbits, memLevel):
8183
decompressed = isal_zlib.decompress(compressed, wbits=wbits)
8284
assert data == decompressed
8385

86+
8487
@pytest.mark.parametrize(["data_size", "level"],
8588
itertools.product(DATA_SIZES, range(4)))
8689
def test_decompress_isal_zlib(data_size, level):
@@ -92,7 +95,7 @@ def test_decompress_isal_zlib(data_size, level):
9295

9396

9497
@pytest.mark.parametrize(["data_size", "level", "wbits", "memLevel"],
95-
itertools.product([128* 1024], range(4),
98+
itertools.product([128 * 1024], range(4),
9699
WBITS_RANGE, range(1, 10)))
97100
def test_compress_compressobj(data_size, level, wbits, memLevel):
98101
data = DATA[:data_size]
@@ -110,7 +113,7 @@ def test_compress_compressobj(data_size, level, wbits, memLevel):
110113

111114

112115
@pytest.mark.parametrize(["data_size", "level", "wbits", "memLevel"],
113-
itertools.product([128* 1024], range(4),
116+
itertools.product([128 * 1024], range(4),
114117
WBITS_RANGE, range(1, 10)))
115118
def test_decompress_decompressobj(data_size, level, wbits, memLevel):
116119
data = DATA[:data_size]

0 commit comments

Comments
 (0)