Light progress reporting tool for Python
Project description
This is a progress reporting tool for Python.
ProgressBar.iteration(range(42), lambda item: sleep(0.01))
# [▉..............................] 1% (1/42)
# [███████████████▉...............] 50% (21/42)
# [███████████████████████████████] 100% (42/42)
Installation
pip install light-progress
Examples
Import
from time import sleep
from light_progress 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
You can execute a iteration within with statement. You don’t have to call start() and finish() 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 |
Failure |
Red |
Customize
from light_progress import Colors, MessageType
colors = {
MessageType.COURSE: Colors.YELLOW,
MessageType.COMPLETE: Colors.BLUE,
}
ProgressBar.iteration(range(100), lambda item: sleep(0.01), colors=colors)
Widgets
ProgressBar can change its 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)
Print text
from light_progress import puts
for item in ProgressBar.generation(range(42)):
sleep(0.01)
puts('item {}'.format(item))
# ...
# item 17
# item 18
# item 19
# [███████████████▉...............] 50% (21/42)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file light-progress-0.7.0.0.tar.gz
.
File metadata
- Download URL: light-progress-0.7.0.0.tar.gz
- Upload date:
- Size: 6.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b029ef8ee1b288810269862e2a5750b5e681a4afd5bab8f062ad4fc491d8f236 |
|
MD5 | 17ea563b212518bdafd5c5f35317336f |
|
BLAKE2b-256 | df9646f14bde5c3b2dfe9f6a34e6c470bafa9beca1293f563561bb71eb631d4c |
File details
Details for the file light_progress-0.7.0.0-py3-none-any.whl
.
File metadata
- Download URL: light_progress-0.7.0.0-py3-none-any.whl
- Upload date:
- Size: 6.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 36bad4b4899c4386b2b32f9de729e17ad973a284d23d0f4c4a3c05b83f849d58 |
|
MD5 | e8e061dbfccda9ec433f4ced90048c9e |
|
BLAKE2b-256 | d76a0f2f8ed59194768a51b151395a5bb6474e6f2956f8375287e89dea7f69a2 |