Skip to content

Commit e198a3d

Browse files
authored
Merge pull request #2 from afq984/master
fix a ZeroDivisonError when cumulative_size is zero
2 parents f080c3c + f593e6f commit e198a3d

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

pyminifier/__init__.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,8 +267,11 @@ def pyminify(options, files):
267267
print((
268268
"{sourcefile} ({filesize}) reduced to {new_filesize} bytes "
269269
"({percent_saved}% of original size)").format(**locals()))
270-
p_saved = round(
271-
(float(cumulative_new) / float(cumulative_size) * 100), 2)
270+
if cumulative_size:
271+
p_saved = round(
272+
(float(cumulative_new) / float(cumulative_size) * 100), 2)
273+
else:
274+
p_saved = 0
272275
print("Overall size reduction: {0}% of original size".format(p_saved))
273276
else:
274277
# Get the module name from the path

0 commit comments

Comments
 (0)