From f593e6f4d394367c56ba7f9c3c043b5c0767a995 Mon Sep 17 00:00:00 2001 From: afg Date: Fri, 4 Aug 2017 10:01:38 +0800 Subject: [PATCH] fix a ZeroDivisonError when cumulative_size is zero --- pyminifier/__init__.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pyminifier/__init__.py b/pyminifier/__init__.py index 0e61063..e66b96a 100644 --- a/pyminifier/__init__.py +++ b/pyminifier/__init__.py @@ -267,8 +267,11 @@ def pyminify(options, files): print(( "{sourcefile} ({filesize}) reduced to {new_filesize} bytes " "({percent_saved}% of original size)").format(**locals())) - p_saved = round( - (float(cumulative_new) / float(cumulative_size) * 100), 2) + if cumulative_size: + p_saved = round( + (float(cumulative_new) / float(cumulative_size) * 100), 2) + else: + p_saved = 0 print("Overall size reduction: {0}% of original size".format(p_saved)) else: # Get the module name from the path