Skip to main content

Python library for creating progress bars

Project description

Voltaire

Voltaire is a Python package for creating nice and colourful progress bars using the map() and apply() method as well as for loops.

Who is Voltaire?

François-Marie Arouet (French: [fʁɑ̃swa maʁi aʁwɛ]; 21 November 1694 – 30 May 1778), known by his nom de plume Voltaire (/vɒlˈtɛər/; French: [vɔltɛːʁ]), was a French Enlightenment writer, historian and philosopher famous for his wit, his criticism of Christianity, especially the Roman Catholic Church, and his advocacy of freedom of religion, freedom of speech, and separation of church and state.

ProgressBar

To use a progress bar you need to initiate a ProgressBar object with the maximum progress amount (total) and call the show method of the object with the amount to update the progress bar.

from lucifer import ProgressBar
from time import sleep

bar = ProgressBar(total=100)

for i in range(100):
  sleep(0.05)
  bar.show(amount=i+1)

You can also add your own text to the progress bar.

from lucifer import ProgressBar
from time import sleep

bar = ProgressBar(total=100)
for i in range(100):
    sleep(0.05)
    bar.show(amount=i+1, text=f'working on {i}')

map

You can also use the ProgressBar's map method instead of Python's map method. The output is an iterable. As soon as you turn the iterable object into a list the progress bar will be displayed.

from lucifer import ProgressBar
from time import sleep

list1 = list(range(100))

def wait_and_double(x, wait_time):
    sleep(wait_time)
    return x*2

# this will not make the progress bar appear
iterable2 = ProgressBar.map(
    function=lambda x: wait_and_double(x=x, wait_time=0.05), 
    iterable=list1
)

# this will make the progress bar appear
list2 = list(iterable2)

apply

ProgressBar also works with Panda's DataFrame and Series objects.

from lucifer import ProgressBar
from time import sleep
from pandas import DataFrame

data = DataFrame({
    'name':['Arminius', 'Boudica', 'Alaric', 'Attila', 'Genseric'],
    'ethnicity': ['German', 'Celt', 'Goth', 'Hun', 'Vandal']
})

data['name_and_ethnicity'] = ProgressBar.apply(
    data=data, 
    function=lambda x: x['name']+' the '+x['ethnicity']
)

data['name_lower'] = ProgressBar.apply(
    series=data['name'], 
    function=lambda x: x.lower()
)

iterate

You can also use ProgressBar to for iterating over iterable objects, especially for loops.

from lucifer import iterate

for i in iterate(range(100)):
    # do something
    pass

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lucifer-1.2.tar.gz (5.6 kB view hashes)

Uploaded Source

Built Distribution

lucifer-1.2-py3-none-any.whl (11.7 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page