Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 25 additions & 12 deletions 37 docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,7 @@
# General information about the project.
project = u'Progress Bar'
project_slug = ''.join(project.capitalize().split())
copyright = u'%s, <a href="http://wol.ph/">%s</a>' % (
datetime.date.today().year,
metadata.__author__,
)
copyright = f'{datetime.date.today().year}, <a href="http://wol.ph/">{metadata.__author__}</a>'
Comment thread
wolph marked this conversation as resolved.

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
Expand Down Expand Up @@ -190,7 +187,7 @@
# html_file_suffix = None

# Output file base name for HTML help builder.
htmlhelp_basename = '%sdoc' % project_slug
htmlhelp_basename = f'{project_slug}doc'


# -- Options for LaTeX output --------------------------------------------
Expand All @@ -209,8 +206,13 @@
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, documentclass [howto/manual]).
latex_documents = [
('index', '%s.tex' % project_slug, u'%s Documentation' % project,
metadata.__author__, 'manual'),
(
'index',
f'{project_slug}.tex',
f'{project} Documentation',
metadata.__author__,
'manual',
)
]

# The name of an image file (relative to this directory) to place at the top of
Expand Down Expand Up @@ -239,8 +241,13 @@
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
('index', project_slug.lower(), u'%s Documentation' % project,
[metadata.__author__], 1)
(
'index',
project_slug.lower(),
f'{project} Documentation',
[metadata.__author__],
1,
)
]

# If true, show URL addresses after external links.
Expand All @@ -253,9 +260,15 @@
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
('index', project_slug, u'%s Documentation' % project,
metadata.__author__, project_slug, 'One line description of project.',
'Miscellaneous'),
(
'index',
project_slug,
f'{project} Documentation',
metadata.__author__,
project_slug,
'One line description of project.',
'Miscellaneous',
)
]

# Documents to append as an appendix to all manuals.
Expand Down
67 changes: 33 additions & 34 deletions 67 examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,19 @@ def fast_example():

@example
def shortcut_example():
for i in progressbar.progressbar(range(10)):
for _ in progressbar.progressbar(range(10)):

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function shortcut_example refactored with the following changes:

time.sleep(0.1)


@example
def prefixed_shortcut_example():
for i in progressbar.progressbar(range(10), prefix='Hi: '):
for _ in progressbar.progressbar(range(10), prefix='Hi: '):

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function prefixed_shortcut_example refactored with the following changes:

time.sleep(0.1)


@example
def templated_shortcut_example():
for i in progressbar.progressbar(range(10), suffix='{seconds_elapsed:.1}'):
for _ in progressbar.progressbar(range(10), suffix='{seconds_elapsed:.1}'):

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function templated_shortcut_example refactored with the following changes:

time.sleep(0.1)


Expand Down Expand Up @@ -142,18 +142,14 @@ def multi_range_bar_example():

@example
def multi_progress_bar_example(left=True):
jobs = [
# Each job takes between 1 and 10 steps to complete
[0, random.randint(1, 10)]
for i in range(25) # 25 jobs total
]
jobs = [[0, random.randint(1, 10)] for _ in range(25)]

widgets = [
progressbar.Percentage(),
' ', progressbar.MultiProgressBar('jobs', fill_left=left),
]

max_value = sum([total for progress, total in jobs])
max_value = sum(total for progress, total in jobs)
Comment on lines -145 to +152

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function multi_progress_bar_example refactored with the following changes:

This removes the following comments ( why? ):

# Each job takes between 1 and 10 steps to complete
# 25 jobs total

with progressbar.ProgressBar(widgets=widgets, max_value=max_value) as bar:
while True:
incomplete_jobs = [
Expand All @@ -165,7 +161,7 @@ def multi_progress_bar_example(left=True):
break
which = random.choice(incomplete_jobs)
jobs[which][0] += 1
progress = sum([progress for progress, total in jobs])
progress = sum(progress for progress, total in jobs)

bar.update(progress, jobs=jobs, force=True)
time.sleep(0.02)
Expand All @@ -181,10 +177,10 @@ def granular_progress_example():
progressbar.GranularBar(markers=" ⡀⡄⡆⡇⣇⣧⣷⣿", left='', right='|'),
progressbar.GranularBar(markers=" .oO", left='', right=''),
]
for i in progressbar.progressbar(list(range(100)), widgets=widgets):
for _ in progressbar.progressbar(list(range(100)), widgets=widgets):
time.sleep(0.03)

for i in progressbar.progressbar(iter(range(100)), widgets=widgets):
for _ in progressbar.progressbar(iter(range(100)), widgets=widgets):
Comment on lines -184 to +183

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function granular_progress_example refactored with the following changes:

time.sleep(0.03)


Expand Down Expand Up @@ -216,17 +212,20 @@ def file_transfer_example():

@example
def custom_file_transfer_example():



class CrazyFileTransferSpeed(progressbar.FileTransferSpeed):
'''
It's bigger between 45 and 80 percent
'''
def update(self, bar):
if 45 < bar.percentage() < 80:
return 'Bigger Now ' + progressbar.FileTransferSpeed.update(
self, bar)
return f'Bigger Now {progressbar.FileTransferSpeed.update(self, bar)}'
else:
return progressbar.FileTransferSpeed.update(self, bar)

Comment on lines +215 to 227

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function custom_file_transfer_example refactored with the following changes:


widgets = [
CrazyFileTransferSpeed(),
' <<<', progressbar.Bar(), '>>> ',
Expand Down Expand Up @@ -300,23 +299,23 @@ def basic_progress():
def progress_with_automatic_max():
# Progressbar can guess max_value automatically.
bar = progressbar.ProgressBar()
for i in bar(range(8)):
for _ in bar(range(8)):
Comment on lines -303 to +302

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function progress_with_automatic_max refactored with the following changes:

time.sleep(0.1)


@example
def progress_with_unavailable_max():
# Progressbar can't guess max_value.
bar = progressbar.ProgressBar(max_value=8)
for i in bar((i for i in range(8))):
for _ in bar(iter(range(8))):
Comment on lines -311 to +310

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function progress_with_unavailable_max refactored with the following changes:

time.sleep(0.1)


@example
def animated_marker():
bar = progressbar.ProgressBar(
widgets=['Working: ', progressbar.AnimatedMarker()])
for i in bar((i for i in range(5))):
for _ in bar(iter(range(5))):
Comment on lines -319 to +318

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function animated_marker refactored with the following changes:

time.sleep(0.1)


Expand All @@ -327,7 +326,7 @@ def filling_bar_animated_marker():
marker=progressbar.AnimatedMarker(fill='#'),
),
])
for i in bar(range(15)):
for _ in bar(range(15)):
Comment on lines -330 to +329

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function filling_bar_animated_marker refactored with the following changes:

time.sleep(0.1)


Expand All @@ -336,7 +335,7 @@ def counter_and_timer():
widgets = ['Processed: ', progressbar.Counter('Counter: %(value)05d'),
' lines (', progressbar.Timer(), ')']
bar = progressbar.ProgressBar(widgets=widgets)
for i in bar((i for i in range(15))):
for _ in bar(iter(range(15))):
Comment on lines -339 to +338

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function counter_and_timer refactored with the following changes:

time.sleep(0.1)


Expand All @@ -345,15 +344,15 @@ def format_label():
widgets = [progressbar.FormatLabel(
'Processed: %(value)d lines (in: %(elapsed)s)')]
bar = progressbar.ProgressBar(widgets=widgets)
for i in bar((i for i in range(15))):
for _ in bar(iter(range(15))):
Comment on lines -348 to +347

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function format_label refactored with the following changes:

time.sleep(0.1)


@example
def animated_balloons():
widgets = ['Balloon: ', progressbar.AnimatedMarker(markers='.oO@* ')]
bar = progressbar.ProgressBar(widgets=widgets)
for i in bar((i for i in range(24))):
for _ in bar(iter(range(24))):
Comment on lines -356 to +355

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function animated_balloons refactored with the following changes:

time.sleep(0.1)


Expand All @@ -363,7 +362,7 @@ def animated_arrows():
try:
widgets = ['Arrows: ', progressbar.AnimatedMarker(markers='←↖↑↗→↘↓↙')]
bar = progressbar.ProgressBar(widgets=widgets)
for i in bar((i for i in range(24))):
for _ in bar(iter(range(24))):
Comment on lines -366 to +365

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function animated_arrows refactored with the following changes:

time.sleep(0.1)
except UnicodeError:
sys.stdout.write('Unicode error: skipping example')
Expand All @@ -375,7 +374,7 @@ def animated_filled_arrows():
try:
widgets = ['Arrows: ', progressbar.AnimatedMarker(markers='◢◣◤◥')]
bar = progressbar.ProgressBar(widgets=widgets)
for i in bar((i for i in range(24))):
for _ in bar(iter(range(24))):
Comment on lines -378 to +377

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function animated_filled_arrows refactored with the following changes:

time.sleep(0.1)
except UnicodeError:
sys.stdout.write('Unicode error: skipping example')
Expand All @@ -387,7 +386,7 @@ def animated_wheels():
try:
widgets = ['Wheels: ', progressbar.AnimatedMarker(markers='◐◓◑◒')]
bar = progressbar.ProgressBar(widgets=widgets)
for i in bar((i for i in range(24))):
for _ in bar(iter(range(24))):
Comment on lines -390 to +389

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function animated_wheels refactored with the following changes:

time.sleep(0.1)
except UnicodeError:
sys.stdout.write('Unicode error: skipping example')
Expand All @@ -400,7 +399,7 @@ def format_label_bouncer():
progressbar.BouncingBar(),
]
bar = progressbar.ProgressBar(widgets=widgets)
for i in bar((i for i in range(100))):
for _ in bar(iter(range(100))):
Comment on lines -403 to +402

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function format_label_bouncer refactored with the following changes:

time.sleep(0.01)


Expand All @@ -410,7 +409,7 @@ def format_label_rotating_bouncer():
progressbar.BouncingBar(marker=progressbar.RotatingMarker())]

bar = progressbar.ProgressBar(widgets=widgets)
for i in bar((i for i in range(18))):
for _ in bar(iter(range(18))):
Comment on lines -413 to +412

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function format_label_rotating_bouncer refactored with the following changes:

time.sleep(0.1)


Expand Down Expand Up @@ -488,7 +487,7 @@ def incrementing_bar():
progressbar.Percentage(),
progressbar.Bar(),
], max_value=10).start()
for i in range(10):
for _ in range(10):
Comment on lines -491 to +490

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function incrementing_bar refactored with the following changes:

# do something
time.sleep(0.1)
bar += 1
Expand Down Expand Up @@ -545,7 +544,7 @@ def adaptive_eta_without_value_change():
progressbar.AdaptiveTransferSpeed(),
], max_value=2, poll_interval=0.0001)
bar.start()
for i in range(100):
for _ in range(100):
Comment on lines -548 to +547

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function adaptive_eta_without_value_change refactored with the following changes:

bar.update(1)
time.sleep(0.1)
bar.finish()
Expand All @@ -556,7 +555,7 @@ def iterator_with_max_value():
# Testing using progressbar as an iterator with a max value
bar = progressbar.ProgressBar()

for n in bar(iter(range(100)), 100):
for _ in bar(iter(range(100)), 100):
Comment on lines -559 to +558

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function iterator_with_max_value refactored with the following changes:

# iter range is a way to get an iterator in both python 2 and 3
pass

Expand Down Expand Up @@ -622,12 +621,12 @@ def user_variables():
num_subtasks = sum(len(x) for x in tasks.values())

with progressbar.ProgressBar(
prefix='{variables.task} >> {variables.subtask}',
variables={'task': '--', 'subtask': '--'},
max_value=10 * num_subtasks) as bar:
prefix='{variables.task} >> {variables.subtask}',
variables={'task': '--', 'subtask': '--'},
max_value=10 * num_subtasks) as bar:
for tasks_name, subtasks in tasks.items():
for subtask_name in subtasks:
for i in range(10):
for _ in range(10):
Comment on lines -625 to +629

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function user_variables refactored with the following changes:

bar.update(bar.value + 1, task=tasks_name,
subtask=subtask_name)
time.sleep(0.1)
Expand Down Expand Up @@ -656,7 +655,7 @@ def format_custom_text():
@example
def simple_api_example():
bar = progressbar.ProgressBar(widget_kwargs=dict(fill='█'))
for i in bar(range(200)):
for _ in bar(range(200)):
Comment on lines -659 to +658

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function simple_api_example refactored with the following changes:

time.sleep(0.02)


Expand Down
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.