python-progressbar icon indicating copy to clipboard operation
python-progressbar copied to clipboard

`with`

Open kousu opened this issue 4 years ago • 3 comments

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.

kousu avatar Jun 29 '20 07:06 kousu

Yeah, that's a good idea. I like it. I think it's convenient

NiltonVolpato avatar Jul 15 '20 09:07 NiltonVolpato

I just pushed a pull request that does this.

thorwhalen avatar Jun 09 '21 15:06 thorwhalen

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

thorwhalen avatar Jun 09 '21 15:06 thorwhalen