Giter Club home page Giter Club logo

progressbar's Introduction

Python Progressbar

A progressbar utility for command line programs. Progressbar is a Python module which contains two class so far:

ProgressBar
AnimatedProgressBar

ProgressBar class implements all the base stuffs that makes progress bars work as they does and admit some basic customization. AnimatedProgressBar class extends ProgressBar to allow you to use it straightforward in your scripts. By default the AnimatedProgressBar sends the output to sys.stdout but you can change this passing a the stdout keyword parameter which must be a file-like object.

Here is some basic usage with the default options:

>>> from progressbar import ProgressBar
>>> p = ProgressBar()
>>> print p
[>............] 0%
>>> p + 1
>>> print p
[=>...........] 10%
>>> p + 9
>>> print p
[============>] 0%

And here another example with different options:

>>> from progressbar import ProgressBar
>>> custom_options = {
...     'end': 100, 
...     'width': 20, 
...     'fill': '#',
...     'format': '%(progress)s%% [%(fill)s%(blank)s]'
... }
>>> p = ProgressBar(**custom_options)
>>> print p
0% [....................]
>>> p + 5
>>> print p
5% [#...................]
>>> p + 9
>>> print p
100% [####################]

Finally, a real example where I had to use it:

>>> import ftplib
>>> import progressbar
>>>
>>> ftp = ftplib.FTP('ftp.myserver.com', 'user', 'passwd')
>>> filesize = ftp.size('path/to/remotefile.zip')
>>> progress = progressbar.AnimatedProgressBar(end=filesize, width=50)
>>>
>>> with open('localfile.zip', 'w') as f:
>>>		def callback(chunk):
>>>			f.write(chunk)
>>>			progress + len(chunk)
>>>
>>>			# Visual feedback of the progress!
>>>			progress.show_progress()
>>>		
>>>		ftp.retrbinary('RETR path/to/remotefile.zip', callback)

progressbar's People

Contributors

hgrzywacz avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.