python-progressbar
python-progressbar copied to clipboard
`with`
It would be cool if I could write:
with ProgressBar(widgets=widgets, maxval=os.stat(fname).st_size) as pbar:
fp = open(fname, 'rb')
fp = ProgressFile(fp, pbar.update)
client.uploadFile(dataset, fp, posixpath.join(dir, file))
With pbar.start()
and pbar.finish()
sequestered into pbar.__enter__
and pbar.__exit__
respectively.
Yeah, that's a good idea. I like it. I think it's convenient
I just pushed a pull request that does this.
Here: https://github.com/niltonvolpato/python-progressbar/pull/78. If it's not merged, you can simply use the fork: https://github.com/thorwhalen/python-progressbar