pyminifier icon indicating copy to clipboard operation
pyminifier copied to clipboard

ZeroDivisionError for running pyminifier tool on multiple files, one of which being empty

Open deeplook opened this issue 10 years ago • 1 comments

I found the pyminifier command-line tool to have issues when run on multiples files while one of them is empty, which then raises a ZeroDivisionError, see below. Tested on pyminifier version 2.1 on OS X 10.10, Python 2.7.8 (same on Python 3.4.2):

$ pyminifier --version
2.1
$ touch __init__.py
$ pyminifier __init__.py
# Created by pyminifier (https://github.com/liftoff/pyminifier)

$ pyminifier __init__.py __init__.py
Traceback (most recent call last):
  File "/opt/bin/pyminifier", line 9, in <module>
    load_entry_point('pyminifier==2.1', 'console_scripts', 'pyminifier')()
  File "/opt/lib/python2.7/site-packages/pyminifier/pyminifier.py", line 383, in main
    (float(new_filesize) / float(filesize)) * 100, 2)
ZeroDivisionError: float division by zero

deeplook avatar Mar 17 '15 21:03 deeplook

add fix with #51

sejans avatar Dec 28 '15 00:12 sejans