Skip to content

Commit

Permalink
Better if/else branching.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kentzo committed Nov 1, 2018
1 parent c89a03d commit ec52ca9
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions git_archive_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,15 +149,12 @@ def create(self, output_path, dry_run=False, output_format=None, compresslevel=N
if output_format in self.ZIPFILE_FORMATS:
from zipfile import ZipFile, ZipInfo, ZIP_DEFLATED

if sys.version_info > (3, 7):
if compresslevel is not None:
if compresslevel is not None:
if sys.version_info > (3, 7):
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+")

else:
archive = ZipFile(path.abspath(output_path), 'w')

def add_file(file_path, arcname):
Expand All @@ -173,15 +170,12 @@ def add_file(file_path, arcname):

mode = self.TARFILE_FORMATS[output_format]

try:
if compresslevel is not None:
if compresslevel is not None:
try:
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:
except TypeError:
raise ValueError("{0} cannot be compressed".format(output_format))

else:
archive = tarfile.open(path.abspath(output_path), mode)

def add_file(file_path, arcname):
Expand Down

0 comments on commit ec52ca9

Please sign in to comment.