Skip to main content

Light progress reporting tool for Python

Project description

This is progress reporting tool for Python

n = 42
with ProgressBar(n) as progress_bar:
    for item in range(n):
        sleep(0.01)
        progress_bar.forward()
# [▉..............................] 1% (1/42)
# [███████████████▉...............] 50% (21/42)
# [███████████████████████████████] 100% (42/42)

Installation

pip install light-progress

Examples

Import

from time import sleep
from light_progress.commandline import ProgressBar

Pattern 1

Call start forward and finish yourself.

n = 42
progress_bar = ProgressBar(n)
progress_bar.start()

for item in range(n):
    sleep(0.01)
    progress_bar.forward()

progress_bar.finish()

Pattern 2

Do iterations in with. start and finish do not have to be called explicitly.

n = 42
with ProgressBar(n) as progress_bar:
    for item in range(n):
        sleep(0.01)
        progress_bar.forward()

Pattern 3

Transfer iteration. You don’t have to call any ProgressBar methods yourself.

ProgressBar.iteration(range(42), lambda item: sleep(0.01))

Pattern 4

Transfer generation. You don’t have to call any ProgressBar methods yourself.

for item in ProgressBar.generation(range(42)):
    sleep(0.01)

Colors

status

color

In progress

Blue

Success

Green

Failur

Red

Widgets

ProgressBar can change the display format using widget.

from light_progress import widget
widgets = [widget.Bar(bar='=', tip='-'),
           widget.Percentage(),
           widget.Num()]

ProgressBar.iteration(
    range(42), lambda item: sleep(0.01), widgets=widgets)

# [===============-...............] 50% (21/42)
widgets = [widget.Percentage(),
           widget.Num(),
           'loading...',
           widget.Bar(bar='#', tip='>')]

ProgressBar.iteration(
    range(42), lambda item: sleep(0.01), widgets=widgets)

# 50% (21/42) loading... [###############>...............]

Formats

format_str = '{} {} ({})'

widgets = [widget.Bar(), widget.Percentage(), widget.Num()]
ProgressBar.iteration(
    range(100),
    lambda item: sleep(0.01),
    widgets=widgets,
    format_str=format_str)

# [███████████████████████████████] 100% (100/100)
format_str = '{} *** {} *** ({})'

widgets = [widget.Bar(), widget.Percentage(), widget.Num()]
ProgressBar.iteration(
    range(100),
    lambda item: sleep(0.01),
    widgets=widgets,
    format_str=format_str)

# [███████████████████████████████] *** 100% *** (100/100)

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

light-progress-0.1.4.tar.gz (3.9 kB view details)

Uploaded Source

File details

Details for the file light-progress-0.1.4.tar.gz.

File metadata

File hashes

Hashes for light-progress-0.1.4.tar.gz
Algorithm Hash digest
SHA256 50a9f8484fb41143566ae57e493ae30dd63615f627af12413843f612ec5a0643
MD5 28e7ede585da269597feb58a26555f9b
BLAKE2b-256 541bd5429163181b9679d7737ac068524d88bf6c2617dbe7f64c6964239780a1

See more details on using hashes here.

Supported by

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