Skip to content

Commit 5626da3

Browse files
committed
Merge branch 'release/v3.46.0'
2 parents fa7b1cc + 9e7a84e commit 5626da3

16 files changed

+607
-233
lines changed

examples.py

Lines changed: 37 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,17 @@ def basic_widget_example():
7171
bar.finish()
7272

7373

74+
@example
75+
def color_bar_example():
76+
widgets = ['\x1b[33mColorful example\x1b[39m', progressbar.Percentage(), progressbar.Bar(marker='\x1b[32m#\x1b[39m')]
77+
bar = progressbar.ProgressBar(widgets=widgets, max_value=10).start()
78+
for i in range(10):
79+
# do something
80+
time.sleep(0.1)
81+
bar.update(i + 1)
82+
bar.finish()
83+
84+
7485
@example
7586
def file_transfer_example():
7687
widgets = [
@@ -89,9 +100,9 @@ def file_transfer_example():
89100
@example
90101
def custom_file_transfer_example():
91102
class CrazyFileTransferSpeed(progressbar.FileTransferSpeed):
92-
93-
"It's bigger between 45 and 80 percent"
94-
103+
'''
104+
It's bigger between 45 and 80 percent
105+
'''
95106
def update(self, bar):
96107
if 45 < bar.percentage() < 80:
97108
return 'Bigger Now ' + progressbar.FileTransferSpeed.update(
@@ -392,6 +403,7 @@ def eta_types_demonstration():
392403
' ETA: ', progressbar.ETA(),
393404
' Adaptive ETA: ', progressbar.AdaptiveETA(),
394405
' Absolute ETA: ', progressbar.AbsoluteETA(),
406+
' Transfer Speed: ', progressbar.FileTransferSpeed(),
395407
' Adaptive Transfer Speed: ', progressbar.AdaptiveTransferSpeed(),
396408
' ', progressbar.Bar(),
397409
]
@@ -448,49 +460,54 @@ def eta():
448460

449461

450462
@example
451-
def dynamic_message():
463+
def variables():
452464
# Use progressbar.Variable to keep track of some parameter(s) during
453465
# your calculations
454466
widgets = [
455467
progressbar.Percentage(),
456468
progressbar.Bar(),
457469
progressbar.Variable('loss'),
470+
', ',
458471
progressbar.Variable('username', width=12, precision=12),
459472
]
460473
with progressbar.ProgressBar(max_value=100, widgets=widgets) as bar:
461474
min_so_far = 1
462475
for i in range(100):
476+
time.sleep(0.01)
463477
val = random.random()
464478
if val < min_so_far:
465479
min_so_far = val
466-
bar.update(i, loss=min_so_far, username='Some user %02d' % i)
480+
bar.update(i, loss=min_so_far, username='Some user')
467481

468482

469483
@example
470484
def user_variables():
471485
tasks = {
472-
"Download": [
473-
"SDK",
474-
"IDE",
475-
"Dependencies",
486+
'Download': [
487+
'SDK',
488+
'IDE',
489+
'Dependencies',
476490
],
477-
"Build": [
478-
"Compile",
479-
"Link",
491+
'Build': [
492+
'Compile',
493+
'Link',
480494
],
481-
"Test": [
482-
"Unit tests",
483-
"Integration tests",
484-
"Regression tests",
495+
'Test': [
496+
'Unit tests',
497+
'Integration tests',
498+
'Regression tests',
485499
],
486-
"Deploy": [
487-
"Send to server",
488-
"Restart server",
500+
'Deploy': [
501+
'Send to server',
502+
'Restart server',
489503
],
490504
}
491505
num_subtasks = sum(len(x) for x in tasks.values())
492506

493-
with progressbar.ProgressBar(prefix="{vars.task} >> {vars.subtask}", vars={"task": '--', "subtask": '--'}, max_value=10*num_subtasks) as bar:
507+
with progressbar.ProgressBar(
508+
prefix='{variables.task} >> {variables.subtask}',
509+
variables={'task': '--', 'subtask': '--'},
510+
max_value=10*num_subtasks) as bar:
494511
for tasks_name, subtasks in tasks.items():
495512
for subtask_name in subtasks:
496513
for i in range(10):

progressbar/__about__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
long running operations.
2020
'''.strip().split())
2121
__email__ = 'wolph@wol.ph'
22-
__version__ = '3.45.0'
22+
__version__ = '3.46.0'
2323
__license__ = 'BSD'
2424
__copyright__ = 'Copyright 2015 Rick van Hattem (Wolph)'
2525
__url__ = 'https://github.com/WoLpH/python-progressbar'

progressbar/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
'ProgressBar',
6767
'DataTransferBar',
6868
'RotatingMarker',
69+
'Variable',
6970
'DynamicMessage',
7071
'FormatCustomText',
7172
'CurrentTime',

0 commit comments

Comments
 (0)