Skip to content

Commit 38c6f22

Browse files
committed
Adopt black and isort style
Signed-off-by: Philippe Ombredanne <[email protected]>
1 parent 1203172 commit 38c6f22

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+2832
-2640
lines changed

src/commoncode/__init__.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,16 @@ def set_re_max_cache(max_cache=1000000):
1414
libraries use a lot of regexes: therefore 100 is not enough to benefit from
1515
caching.
1616
"""
17-
import re
1817
import fnmatch
18+
import re
1919

20-
remax = getattr(re, '_MAXCACHE', 0)
20+
remax = getattr(re, "_MAXCACHE", 0)
2121
if remax < max_cache:
22-
setattr(re, '_MAXCACHE', max_cache)
22+
setattr(re, "_MAXCACHE", max_cache)
2323

24-
fnmatchmax = getattr(fnmatch, '_MAXCACHE', 0)
24+
fnmatchmax = getattr(fnmatch, "_MAXCACHE", 0)
2525
if fnmatchmax < max_cache:
26-
setattr(fnmatch, '_MAXCACHE', max_cache)
26+
setattr(fnmatch, "_MAXCACHE", max_cache)
2727

2828

2929
set_re_max_cache()

src/commoncode/archive.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
# See https://aboutcode.org for more information about nexB OSS projects.
77
#
88

9-
from functools import partial
10-
import os
11-
from os import path
129
import gzip
10+
import os
1311
import tarfile
1412
import zipfile
13+
from functools import partial
14+
from os import path
1515

1616
from commoncode.system import on_windows
1717

@@ -47,7 +47,7 @@ def extract_tar(location, target_dir, verbatim=False, *args, **kwargs):
4747
# always for using bytes for paths on all OSses... tar seems to use bytes internally
4848
# and get confused otherwise
4949
location = os.fsencode(location)
50-
with open(location, 'rb') as input_tar:
50+
with open(location, "rb") as input_tar:
5151
tar = None
5252
try:
5353
tar = tarfile.open(fileobj=input_tar)
@@ -69,7 +69,7 @@ def extract_zip(location, target_dir, *args, **kwargs):
6969
Extract a zip archive file at location in the target_dir directory.
7070
"""
7171
if not path.isfile(location) and zipfile.is_zipfile(location):
72-
raise Exception('Incorrect zip file %(location)r' % locals())
72+
raise Exception("Incorrect zip file %(location)r" % locals())
7373

7474
with zipfile.ZipFile(location) as zipf:
7575
for info in zipf.infolist():
@@ -82,7 +82,7 @@ def extract_zip(location, target_dir, *args, **kwargs):
8282
if not path.exists(target):
8383
os.makedirs(target)
8484
if not path.exists(target):
85-
with open(target, 'wb') as f:
85+
with open(target, "wb") as f:
8686
f.write(content)
8787

8888

@@ -92,7 +92,7 @@ def extract_zip_raw(location, target_dir, *args, **kwargs):
9292
Use the builtin extractall function
9393
"""
9494
if not path.isfile(location) and zipfile.is_zipfile(location):
95-
raise Exception('Incorrect zip file %(location)r' % locals())
95+
raise Exception("Incorrect zip file %(location)r" % locals())
9696

9797
with zipfile.ZipFile(location) as zipf:
9898
zipf.extractall(path=target_dir)
@@ -124,6 +124,6 @@ def get_gz_compressed_file_content(location):
124124
Uncompress a compressed file at `location` and return its content as a byte
125125
string. Raise Exceptions on errors.
126126
"""
127-
with gzip.GzipFile(location, 'rb') as compressed:
127+
with gzip.GzipFile(location, "rb") as compressed:
128128
content = compressed.read()
129129
return content

0 commit comments

Comments
 (0)