mitsuhiko/click — pull request #162 by cournape (2014-06-20 19:04:51+00:00)
Title: Allow non linear progress

I sometimes need to use a progress bar without having an underlying iterable, or more exactly when the progress as a function of iterable position is not linear. In this car, one may want to manually update the progressbar with custom steps.

This small PR allows doing this. I also added the ability to change the label, though I don't really like the API. It is in a separate commit so that it can be easily discarded.

``` python
# Example: unzipping an archive with lots of small files and a few large files:
filename = "some_large_zip_file.zip"
with zipfile.ZipFile(filename) as fp:
archives = [fp.getinfo(member) for member in fp.namelist()]
total_size = sum(archive.file_size for archive in archives)

bar = progressbar(length=total_size, bar_template='%(bar)s - %(label)s')
with bar:
for archive in archives:
fp.extract(archive.filename, "tmp")
bar.update(archive.file_size, "extracting {}".format(archive.filename))
```