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
129import gzip
10+ import os
1311import tarfile
1412import zipfile
13+ from functools import partial
14+ from os import path
1515
1616from 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