NiltonVolpato / python-progressbar

Text progress bar library for Python
Other
412 stars 105 forks source link

0-length files never finish #72

Open kousu opened 4 years ago

kousu commented 4 years ago

A progressbar with maxval=0 doesn't fill its bars on .finish(). I know it's not mathematically sound (0/0 is undefined, not 100%) but I think it should. It means that when I'm uploading 0-length files they stick out weirdly in the log.

$ cat t.py
import sys
from progressbar import *
widgets = [f'fname: ', Percentage(), ' ', Bar(marker=RotatingMarker()),
                           ' ', ETA(), ' ', FileTransferSpeed()]
pbar = ProgressBar(widgets=widgets, maxval=int(sys.argv[1])) 
pbar.start()
pbar.finish()
$ python t.py 0
fname: 100% |                                                                                                             | ETA:  --:--:--   0.00  B/s
$ python t.py 1
fname: 100% |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| Time: 0:00:00   1.52 kB/s
$ python t.py 100
fname: 100% |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| Time: 0:00:00 153.08 kB/s