Skip to content

Commit

Permalink
Do not pass compresslevel unless set by user.
Browse files Browse the repository at this point in the history
Compression lib may not recognize None as a valid value.
  • Loading branch information
Kentzo committed Nov 1, 2018
1 parent b3f9c9d commit c89a03d
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions git_archive_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,10 @@ def create(self, output_path, dry_run=False, output_format=None, compresslevel=N
from zipfile import ZipFile, ZipInfo, ZIP_DEFLATED

if sys.version_info > (3, 7):
archive = ZipFile(path.abspath(output_path), 'w', compresslevel=compresslevel)
if compresslevel is not None:
archive = ZipFile(path.abspath(output_path), 'w', compresslevel=compresslevel)
else:
archive = ZipFile(path.abspath(output_path), 'w')
else:
if compresslevel is not None:
raise ValueError("Compression level for zip archives requires Python 3.7+")
Expand All @@ -171,7 +174,10 @@ def add_file(file_path, arcname):
mode = self.TARFILE_FORMATS[output_format]

try:
archive = tarfile.open(path.abspath(output_path), mode, compresslevel=compresslevel)
if compresslevel is not None:
archive = tarfile.open(path.abspath(output_path), mode, compresslevel=compresslevel)
else:
archive = tarfile.open(path.abspath(output_path), mode)
except TypeError:
if compresslevel is not None:
raise ValueError("{0} cannot be compressed".format(output_format))
Expand Down

0 comments on commit c89a03d

Please sign in to comment.