progressbar2 4.3.2__tar.gz → 4.4.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (120) hide show
  1. {progressbar2-4.3.2 → progressbar2-4.4.1}/PKG-INFO +3 -2
  2. {progressbar2-4.3.2 → progressbar2-4.4.1}/README.rst +1 -1
  3. {progressbar2-4.3.2 → progressbar2-4.4.1}/docs/conf.py +3 -4
  4. progressbar2-4.4.1/docs/progressbar.algorithms.rst +7 -0
  5. progressbar2-4.4.1/docs/progressbar.env.rst +7 -0
  6. {progressbar2-4.3.2 → progressbar2-4.4.1}/docs/progressbar.terminal.os_specific.rst +0 -3
  7. {progressbar2-4.3.2 → progressbar2-4.4.1}/examples.py +131 -69
  8. {progressbar2-4.3.2 → progressbar2-4.4.1}/progressbar/__about__.py +1 -1
  9. {progressbar2-4.3.2 → progressbar2-4.4.1}/progressbar/__init__.py +10 -0
  10. progressbar2-4.4.1/progressbar/__main__.py +396 -0
  11. progressbar2-4.4.1/progressbar/algorithms.py +51 -0
  12. {progressbar2-4.3.2 → progressbar2-4.4.1}/progressbar/bar.py +63 -36
  13. {progressbar2-4.3.2 → progressbar2-4.4.1}/progressbar/env.py +46 -19
  14. {progressbar2-4.3.2 → progressbar2-4.4.1}/progressbar/multi.py +2 -1
  15. {progressbar2-4.3.2 → progressbar2-4.4.1}/progressbar/terminal/base.py +117 -18
  16. {progressbar2-4.3.2 → progressbar2-4.4.1}/progressbar/terminal/os_specific/__init__.py +10 -5
  17. progressbar2-4.4.1/progressbar/terminal/os_specific/posix.py +15 -0
  18. {progressbar2-4.3.2 → progressbar2-4.4.1}/progressbar/terminal/os_specific/windows.py +50 -14
  19. {progressbar2-4.3.2 → progressbar2-4.4.1}/progressbar/widgets.py +58 -3
  20. {progressbar2-4.3.2 → progressbar2-4.4.1}/progressbar2.egg-info/PKG-INFO +3 -2
  21. {progressbar2-4.3.2 → progressbar2-4.4.1}/progressbar2.egg-info/SOURCES.txt +8 -2
  22. progressbar2-4.4.1/progressbar2.egg-info/entry_points.txt +2 -0
  23. {progressbar2-4.3.2 → progressbar2-4.4.1}/progressbar2.egg-info/requires.txt +3 -0
  24. {progressbar2-4.3.2 → progressbar2-4.4.1}/pyproject.toml +4 -2
  25. {progressbar2-4.3.2 → progressbar2-4.4.1}/ruff.toml +35 -8
  26. progressbar2-4.4.1/tests/test_algorithms.py +47 -0
  27. {progressbar2-4.3.2 → progressbar2-4.4.1}/tests/test_color.py +82 -17
  28. {progressbar2-4.3.2 → progressbar2-4.4.1}/tests/test_failure.py +3 -1
  29. {progressbar2-4.3.2 → progressbar2-4.4.1}/tests/test_monitor_progress.py +25 -28
  30. {progressbar2-4.3.2 → progressbar2-4.4.1}/tests/test_progressbar.py +6 -0
  31. progressbar2-4.4.1/tests/test_progressbar_command.py +102 -0
  32. {progressbar2-4.3.2 → progressbar2-4.4.1}/tests/test_stream.py +2 -0
  33. {progressbar2-4.3.2 → progressbar2-4.4.1}/tests/test_utils.py +13 -13
  34. progressbar2-4.4.1/tests/test_windows.py +84 -0
  35. progressbar2-4.3.2/docs/progressbar.terminal.os_specific.posix.rst +0 -7
  36. progressbar2-4.3.2/docs/progressbar.terminal.os_specific.windows.rst +0 -7
  37. progressbar2-4.3.2/progressbar/terminal/os_specific/posix.py +0 -15
  38. {progressbar2-4.3.2 → progressbar2-4.4.1}/.github/FUNDING.yml +0 -0
  39. {progressbar2-4.3.2 → progressbar2-4.4.1}/.github/ci-reporter.yml +0 -0
  40. {progressbar2-4.3.2 → progressbar2-4.4.1}/.github/workflows/codeql.yml +0 -0
  41. {progressbar2-4.3.2 → progressbar2-4.4.1}/.github/workflows/main.yml +0 -0
  42. {progressbar2-4.3.2 → progressbar2-4.4.1}/.github/workflows/stale.yml +0 -0
  43. {progressbar2-4.3.2 → progressbar2-4.4.1}/.gitignore +0 -0
  44. {progressbar2-4.3.2 → progressbar2-4.4.1}/.pre-commit-config.yaml +0 -0
  45. {progressbar2-4.3.2 → progressbar2-4.4.1}/.readthedocs.yaml +0 -0
  46. {progressbar2-4.3.2 → progressbar2-4.4.1}/CHANGES.rst +0 -0
  47. {progressbar2-4.3.2 → progressbar2-4.4.1}/CONTRIBUTING.rst +0 -0
  48. {progressbar2-4.3.2 → progressbar2-4.4.1}/ISSUE_TEMPLATE +0 -0
  49. {progressbar2-4.3.2 → progressbar2-4.4.1}/LICENSE +0 -0
  50. {progressbar2-4.3.2 → progressbar2-4.4.1}/MANIFEST.in +0 -0
  51. {progressbar2-4.3.2 → progressbar2-4.4.1}/Makefile +0 -0
  52. {progressbar2-4.3.2 → progressbar2-4.4.1}/appveyor.yml +0 -0
  53. {progressbar2-4.3.2 → progressbar2-4.4.1}/circle.yml +0 -0
  54. {progressbar2-4.3.2 → progressbar2-4.4.1}/docs/.gitignore +0 -0
  55. {progressbar2-4.3.2 → progressbar2-4.4.1}/docs/Makefile +0 -0
  56. {progressbar2-4.3.2 → progressbar2-4.4.1}/docs/_theme/LICENSE +0 -0
  57. {progressbar2-4.3.2 → progressbar2-4.4.1}/docs/_theme/flask_theme_support.py +7 -7
  58. {progressbar2-4.3.2 → progressbar2-4.4.1}/docs/_theme/wolph/layout.html +0 -0
  59. {progressbar2-4.3.2 → progressbar2-4.4.1}/docs/_theme/wolph/relations.html +0 -0
  60. {progressbar2-4.3.2 → progressbar2-4.4.1}/docs/_theme/wolph/static/flasky.css_t +0 -0
  61. {progressbar2-4.3.2 → progressbar2-4.4.1}/docs/_theme/wolph/static/small_flask.css +0 -0
  62. {progressbar2-4.3.2 → progressbar2-4.4.1}/docs/_theme/wolph/theme.conf +0 -0
  63. {progressbar2-4.3.2 → progressbar2-4.4.1}/docs/contributing.rst +0 -0
  64. {progressbar2-4.3.2 → progressbar2-4.4.1}/docs/examples.rst +0 -0
  65. {progressbar2-4.3.2 → progressbar2-4.4.1}/docs/history.rst +0 -0
  66. {progressbar2-4.3.2 → progressbar2-4.4.1}/docs/index.rst +0 -0
  67. {progressbar2-4.3.2 → progressbar2-4.4.1}/docs/installation.rst +0 -0
  68. {progressbar2-4.3.2 → progressbar2-4.4.1}/docs/make.bat +0 -0
  69. {progressbar2-4.3.2 → progressbar2-4.4.1}/docs/progressbar.bar.rst +0 -0
  70. {progressbar2-4.3.2 → progressbar2-4.4.1}/docs/progressbar.base.rst +0 -0
  71. {progressbar2-4.3.2 → progressbar2-4.4.1}/docs/progressbar.multi.rst +0 -0
  72. {progressbar2-4.3.2 → progressbar2-4.4.1}/docs/progressbar.rst +0 -0
  73. {progressbar2-4.3.2 → progressbar2-4.4.1}/docs/progressbar.shortcuts.rst +0 -0
  74. {progressbar2-4.3.2 → progressbar2-4.4.1}/docs/progressbar.terminal.base.rst +0 -0
  75. {progressbar2-4.3.2 → progressbar2-4.4.1}/docs/progressbar.terminal.colors.rst +0 -0
  76. {progressbar2-4.3.2 → progressbar2-4.4.1}/docs/progressbar.terminal.rst +0 -0
  77. {progressbar2-4.3.2 → progressbar2-4.4.1}/docs/progressbar.terminal.stream.rst +0 -0
  78. {progressbar2-4.3.2 → progressbar2-4.4.1}/docs/progressbar.utils.rst +0 -0
  79. {progressbar2-4.3.2 → progressbar2-4.4.1}/docs/progressbar.widgets.rst +0 -0
  80. {progressbar2-4.3.2 → progressbar2-4.4.1}/docs/requirements.txt +0 -0
  81. {progressbar2-4.3.2 → progressbar2-4.4.1}/docs/usage.rst +0 -0
  82. {progressbar2-4.3.2 → progressbar2-4.4.1}/progressbar/base.py +0 -0
  83. {progressbar2-4.3.2 → progressbar2-4.4.1}/progressbar/py.typed +0 -0
  84. {progressbar2-4.3.2 → progressbar2-4.4.1}/progressbar/shortcuts.py +0 -0
  85. {progressbar2-4.3.2 → progressbar2-4.4.1}/progressbar/terminal/__init__.py +0 -0
  86. {progressbar2-4.3.2 → progressbar2-4.4.1}/progressbar/terminal/colors.py +0 -0
  87. {progressbar2-4.3.2 → progressbar2-4.4.1}/progressbar/terminal/stream.py +0 -0
  88. {progressbar2-4.3.2 → progressbar2-4.4.1}/progressbar/utils.py +0 -0
  89. {progressbar2-4.3.2 → progressbar2-4.4.1}/progressbar2.egg-info/dependency_links.txt +0 -0
  90. {progressbar2-4.3.2 → progressbar2-4.4.1}/progressbar2.egg-info/top_level.txt +0 -0
  91. {progressbar2-4.3.2 → progressbar2-4.4.1}/pytest.ini +0 -0
  92. {progressbar2-4.3.2 → progressbar2-4.4.1}/requirements.txt +0 -0
  93. {progressbar2-4.3.2 → progressbar2-4.4.1}/setup.cfg +0 -0
  94. {progressbar2-4.3.2 → progressbar2-4.4.1}/tests/conftest.py +0 -0
  95. {progressbar2-4.3.2 → progressbar2-4.4.1}/tests/original_examples.py +0 -0
  96. {progressbar2-4.3.2 → progressbar2-4.4.1}/tests/requirements.txt +0 -0
  97. {progressbar2-4.3.2 → progressbar2-4.4.1}/tests/test_backwards_compatibility.py +0 -0
  98. {progressbar2-4.3.2 → progressbar2-4.4.1}/tests/test_custom_widgets.py +0 -0
  99. {progressbar2-4.3.2 → progressbar2-4.4.1}/tests/test_data.py +0 -0
  100. {progressbar2-4.3.2 → progressbar2-4.4.1}/tests/test_data_transfer_bar.py +0 -0
  101. {progressbar2-4.3.2 → progressbar2-4.4.1}/tests/test_dill_pickle.py +0 -0
  102. {progressbar2-4.3.2 → progressbar2-4.4.1}/tests/test_empty.py +0 -0
  103. {progressbar2-4.3.2 → progressbar2-4.4.1}/tests/test_end.py +0 -0
  104. {progressbar2-4.3.2 → progressbar2-4.4.1}/tests/test_flush.py +0 -0
  105. {progressbar2-4.3.2 → progressbar2-4.4.1}/tests/test_iterators.py +0 -0
  106. {progressbar2-4.3.2 → progressbar2-4.4.1}/tests/test_job_status.py +0 -0
  107. {progressbar2-4.3.2 → progressbar2-4.4.1}/tests/test_large_values.py +0 -0
  108. {progressbar2-4.3.2 → progressbar2-4.4.1}/tests/test_misc.py +0 -0
  109. {progressbar2-4.3.2 → progressbar2-4.4.1}/tests/test_multibar.py +0 -0
  110. {progressbar2-4.3.2 → progressbar2-4.4.1}/tests/test_samples.py +0 -0
  111. {progressbar2-4.3.2 → progressbar2-4.4.1}/tests/test_speed.py +0 -0
  112. {progressbar2-4.3.2 → progressbar2-4.4.1}/tests/test_terminal.py +0 -0
  113. {progressbar2-4.3.2 → progressbar2-4.4.1}/tests/test_timed.py +0 -0
  114. {progressbar2-4.3.2 → progressbar2-4.4.1}/tests/test_timer.py +0 -0
  115. {progressbar2-4.3.2 → progressbar2-4.4.1}/tests/test_unicode.py +0 -0
  116. {progressbar2-4.3.2 → progressbar2-4.4.1}/tests/test_unknown_length.py +0 -0
  117. {progressbar2-4.3.2 → progressbar2-4.4.1}/tests/test_widgets.py +0 -0
  118. {progressbar2-4.3.2 → progressbar2-4.4.1}/tests/test_with.py +0 -0
  119. {progressbar2-4.3.2 → progressbar2-4.4.1}/tests/test_wrappingio.py +0 -0
  120. {progressbar2-4.3.2 → progressbar2-4.4.1}/tox.ini +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: progressbar2
3
- Version: 4.3.2
3
+ Version: 4.4.1
4
4
  Summary: A Python Progressbar library to provide visual (yet text based) progress to long running operations.
5
5
  Author-email: "Rick van Hattem (Wolph)" <wolph@wol.ph>
6
6
  License: BSD-3-Clause
@@ -78,6 +78,7 @@ Requires-Dist: pytest-cov>=2.6.1; extra == "tests"
78
78
  Requires-Dist: pytest-mypy; extra == "tests"
79
79
  Requires-Dist: pytest>=4.6.9; extra == "tests"
80
80
  Requires-Dist: sphinx>=1.8.5; extra == "tests"
81
+ Requires-Dist: pywin32; sys_platform == "win32" and extra == "tests"
81
82
 
82
83
  ##############################################################################
83
84
  Text progress bar library for Python.
@@ -385,7 +386,7 @@ Showing multiple independent progress bars in parallel
385
386
  )
386
387
 
387
388
  # Create a file descriptor for regular printing as well
388
- print_fd = progressbar.LineOffsetStreamWrapper(sys.stdout, 0)
389
+ print_fd = progressbar.LineOffsetStreamWrapper(lines=0, stream=sys.stdout)
389
390
 
390
391
  # The progress bar updates, normally you would do something useful here
391
392
  for i in range(N * BARS):
@@ -304,7 +304,7 @@ Showing multiple independent progress bars in parallel
304
304
  )
305
305
 
306
306
  # Create a file descriptor for regular printing as well
307
- print_fd = progressbar.LineOffsetStreamWrapper(sys.stdout, 0)
307
+ print_fd = progressbar.LineOffsetStreamWrapper(lines=0, stream=sys.stdout)
308
308
 
309
309
  # The progress bar updates, normally you would do something useful here
310
310
  for i in range(N * BARS):
@@ -1,4 +1,3 @@
1
- # -*- coding: utf-8 -*-
2
1
  #
3
2
  # Progress Bar documentation build configuration file, created by
4
3
  # sphinx-quickstart on Tue Aug 20 11:47:33 2013.
@@ -11,16 +10,16 @@
11
10
  # All configuration values have a default; values that are commented out
12
11
  # serve to show the default.
13
12
 
13
+ import datetime
14
14
  import os
15
15
  import sys
16
- import datetime
17
16
 
18
17
  # If extensions (or modules to document with autodoc) are in another directory,
19
18
  # add these directories to sys.path here. If the directory is relative to the
20
19
  # documentation root, use os.path.abspath to make it absolute, like shown here.
21
20
  sys.path.insert(0, os.path.abspath('..'))
22
21
 
23
- from progressbar import __about__ as metadata # noqa: E402
22
+ from progressbar import __about__ as metadata
24
23
 
25
24
  # -- General configuration -----------------------------------------------
26
25
 
@@ -59,7 +58,7 @@ source_suffix = '.rst'
59
58
  master_doc = 'index'
60
59
 
61
60
  # General information about the project.
62
- project = u'Progress Bar'
61
+ project = 'Progress Bar'
63
62
  project_slug = ''.join(project.capitalize().split())
64
63
  copyright = f'{datetime.date.today().year}, <a href="http://wol.ph/">{metadata.__author__}</a>'
65
64
 
@@ -0,0 +1,7 @@
1
+ progressbar.algorithms module
2
+ =============================
3
+
4
+ .. automodule:: progressbar.algorithms
5
+ :members:
6
+ :undoc-members:
7
+ :show-inheritance:
@@ -0,0 +1,7 @@
1
+ progressbar.env module
2
+ ======================
3
+
4
+ .. automodule:: progressbar.env
5
+ :members:
6
+ :undoc-members:
7
+ :show-inheritance:
@@ -7,9 +7,6 @@ Submodules
7
7
  .. toctree::
8
8
  :maxdepth: 4
9
9
 
10
- progressbar.terminal.os_specific.posix
11
- progressbar.terminal.os_specific.windows
12
-
13
10
  Module contents
14
11
  ---------------
15
12
 
@@ -1,7 +1,9 @@
1
1
  #!/usr/bin/python
2
- # -*- coding: utf-8 -*-
2
+ from __future__ import annotations
3
3
 
4
+ import contextlib
4
5
  import functools
6
+ import os
5
7
  import random
6
8
  import sys
7
9
  import time
@@ -9,7 +11,7 @@ import typing
9
11
 
10
12
  import progressbar
11
13
 
12
- examples: typing.List[typing.Callable[[typing.Any], typing.Any]] = []
14
+ examples: list[typing.Callable[[typing.Any], typing.Any]] = []
13
15
 
14
16
 
15
17
  def example(fn):
@@ -40,19 +42,83 @@ def fast_example():
40
42
 
41
43
  @example
42
44
  def shortcut_example():
43
- for i in progressbar.progressbar(range(10)):
45
+ for _ in progressbar.progressbar(range(10)):
44
46
  time.sleep(0.1)
45
47
 
46
48
 
47
49
  @example
48
50
  def prefixed_shortcut_example():
49
- for i in progressbar.progressbar(range(10), prefix='Hi: '):
51
+ for _ in progressbar.progressbar(range(10), prefix='Hi: '):
50
52
  time.sleep(0.1)
51
53
 
52
54
 
55
+ @example
56
+ def parallel_bars_multibar_example():
57
+ if os.name == 'nt':
58
+ print('Skipping multibar example on Windows due to threading '
59
+ 'incompatibilities with the example code.')
60
+ return
61
+
62
+ BARS = 5
63
+ N = 50
64
+
65
+ def do_something(bar):
66
+ for _ in bar(range(N)):
67
+ # Sleep up to 0.1 seconds
68
+ time.sleep(random.random() * 0.1)
69
+
70
+ with progressbar.MultiBar() as multibar:
71
+ bar_labels = []
72
+ for i in range(BARS):
73
+ # Get a progressbar
74
+ bar_label = 'Bar #%d' % i
75
+ bar_labels.append(bar_label)
76
+ multibar[bar_label]
77
+
78
+ for _ in range(N * BARS):
79
+ time.sleep(0.005)
80
+
81
+ bar_i = random.randrange(0, BARS)
82
+ bar_label = bar_labels[bar_i]
83
+ # Increment one of the progress bars at random
84
+ multibar[bar_label].increment()
85
+
86
+
87
+ @example
88
+ def multiple_bars_line_offset_example():
89
+ BARS = 5
90
+ N = 100
91
+
92
+ bars = [
93
+ progressbar.ProgressBar(
94
+ max_value=N,
95
+ # We add 1 to the line offset to account for the `print_fd`
96
+ line_offset=i + 1,
97
+ max_error=False,
98
+ )
99
+ for i in range(BARS)
100
+ ]
101
+ # Create a file descriptor for regular printing as well
102
+ print_fd = progressbar.LineOffsetStreamWrapper(lines=0, stream=sys.stdout)
103
+ assert print_fd
104
+
105
+ # The progress bar updates, normally you would do something useful here
106
+ for _ in range(N * BARS):
107
+ time.sleep(0.005)
108
+
109
+ # Increment one of the progress bars at random
110
+ bars[random.randrange(0, BARS)].increment()
111
+
112
+ # Cleanup the bars
113
+ for bar in bars:
114
+ bar.finish()
115
+ # Add a newline to make sure the next print starts on a new line
116
+ print()
117
+
118
+
53
119
  @example
54
120
  def templated_shortcut_example():
55
- for i in progressbar.progressbar(range(10), suffix='{seconds_elapsed:.1}'):
121
+ for _ in progressbar.progressbar(range(10), suffix='{seconds_elapsed:.1}'):
56
122
  time.sleep(0.1)
57
123
 
58
124
 
@@ -62,7 +128,7 @@ def job_status_example():
62
128
  redirect_stdout=True,
63
129
  widgets=[progressbar.widgets.JobStatusBar('status')],
64
130
  ) as bar:
65
- for i in range(30):
131
+ for _ in range(30):
66
132
  print('random', random.random())
67
133
  # Roughly 1/3 probability for each status ;)
68
134
  # Yes... probability is confusing at times
@@ -141,7 +207,7 @@ def multi_range_bar_example():
141
207
  '\x1b[31m.\x1b[39m', # Scheduling
142
208
  ' ', # Not started
143
209
  ]
144
- widgets = [progressbar.MultiRangeBar("amounts", markers=markers)]
210
+ widgets = [progressbar.MultiRangeBar('amounts', markers=markers)]
145
211
  amounts = [0] * (len(markers) - 1) + [25]
146
212
 
147
213
  with progressbar.ProgressBar(widgets=widgets, max_value=10).start() as bar:
@@ -149,7 +215,7 @@ def multi_range_bar_example():
149
215
  incomplete_items = [
150
216
  idx
151
217
  for idx, amount in enumerate(amounts)
152
- for i in range(amount)
218
+ for _ in range(amount)
153
219
  if idx != 0
154
220
  ]
155
221
  if not incomplete_items:
@@ -167,7 +233,7 @@ def multi_progress_bar_example(left=True):
167
233
  jobs = [
168
234
  # Each job takes between 1 and 10 steps to complete
169
235
  [0, random.randint(1, 10)]
170
- for i in range(25) # 25 jobs total
236
+ for _ in range(25) # 25 jobs total
171
237
  ]
172
238
 
173
239
  widgets = [
@@ -197,17 +263,17 @@ def multi_progress_bar_example(left=True):
197
263
  @example
198
264
  def granular_progress_example():
199
265
  widgets = [
200
- progressbar.GranularBar(markers=" ▏▎▍▌▋▊▉█", left='', right='|'),
201
- progressbar.GranularBar(markers=" ▁▂▃▄▅▆▇█", left='', right='|'),
202
- progressbar.GranularBar(markers=" ▖▌▛█", left='', right='|'),
203
- progressbar.GranularBar(markers=" ░▒▓█", left='', right='|'),
204
- progressbar.GranularBar(markers=" ⡀⡄⡆⡇⣇⣧⣷⣿", left='', right='|'),
205
- progressbar.GranularBar(markers=" .oO", left='', right=''),
266
+ progressbar.GranularBar(markers=' ▏▎▍▌▋▊▉█', left='', right='|'),
267
+ progressbar.GranularBar(markers=' ▁▂▃▄▅▆▇█', left='', right='|'),
268
+ progressbar.GranularBar(markers=' ▖▌▛█', left='', right='|'),
269
+ progressbar.GranularBar(markers=' ░▒▓█', left='', right='|'),
270
+ progressbar.GranularBar(markers=' ⡀⡄⡆⡇⣇⣧⣷⣿', left='', right='|'),
271
+ progressbar.GranularBar(markers=' .oO', left='', right=''),
206
272
  ]
207
- for i in progressbar.progressbar(list(range(100)), widgets=widgets):
273
+ for _ in progressbar.progressbar(list(range(100)), widgets=widgets):
208
274
  time.sleep(0.03)
209
275
 
210
- for i in progressbar.progressbar(iter(range(100)), widgets=widgets):
276
+ for _ in progressbar.progressbar(iter(range(100)), widgets=widgets):
211
277
  time.sleep(0.03)
212
278
 
213
279
 
@@ -237,6 +303,7 @@ def file_transfer_example():
237
303
  bar = progressbar.ProgressBar(widgets=widgets, max_value=1000).start()
238
304
  for i in range(100):
239
305
  # do something
306
+ time.sleep(0.01)
240
307
  bar.update(10 * i + 1)
241
308
  bar.finish()
242
309
 
@@ -270,6 +337,7 @@ def custom_file_transfer_example():
270
337
  bar.start()
271
338
  for i in range(200):
272
339
  # do something
340
+ time.sleep(0.01)
273
341
  bar.update(5 * i + 1)
274
342
  bar.finish()
275
343
 
@@ -286,8 +354,8 @@ def double_bar_example():
286
354
  bar = progressbar.ProgressBar(widgets=widgets, max_value=1000).start()
287
355
  for i in range(100):
288
356
  # do something
289
- bar.update(10 * i + 1)
290
357
  time.sleep(0.01)
358
+ bar.update(10 * i + 1)
291
359
  bar.finish()
292
360
 
293
361
 
@@ -337,7 +405,7 @@ def basic_progress():
337
405
  def progress_with_automatic_max():
338
406
  # Progressbar can guess max_value automatically.
339
407
  bar = progressbar.ProgressBar()
340
- for i in bar(range(8)):
408
+ for _ in bar(range(8)):
341
409
  time.sleep(0.1)
342
410
 
343
411
 
@@ -345,7 +413,7 @@ def progress_with_automatic_max():
345
413
  def progress_with_unavailable_max():
346
414
  # Progressbar can't guess max_value.
347
415
  bar = progressbar.ProgressBar(max_value=8)
348
- for i in bar((i for i in range(8))):
416
+ for _ in bar(i for i in range(8)):
349
417
  time.sleep(0.1)
350
418
 
351
419
 
@@ -354,7 +422,7 @@ def animated_marker():
354
422
  bar = progressbar.ProgressBar(
355
423
  widgets=['Working: ', progressbar.AnimatedMarker()]
356
424
  )
357
- for i in bar((i for i in range(5))):
425
+ for _ in bar(i for i in range(5)):
358
426
  time.sleep(0.1)
359
427
 
360
428
 
@@ -367,7 +435,7 @@ def filling_bar_animated_marker():
367
435
  ),
368
436
  ]
369
437
  )
370
- for i in bar(range(15)):
438
+ for _ in bar(range(15)):
371
439
  time.sleep(0.1)
372
440
 
373
441
 
@@ -381,7 +449,7 @@ def counter_and_timer():
381
449
  ')',
382
450
  ]
383
451
  bar = progressbar.ProgressBar(widgets=widgets)
384
- for i in bar((i for i in range(15))):
452
+ for _ in bar(i for i in range(15)):
385
453
  time.sleep(0.1)
386
454
 
387
455
 
@@ -391,7 +459,7 @@ def format_label():
391
459
  progressbar.FormatLabel('Processed: %(value)d lines (in: %(elapsed)s)')
392
460
  ]
393
461
  bar = progressbar.ProgressBar(widgets=widgets)
394
- for i in bar((i for i in range(15))):
462
+ for _ in bar(i for i in range(15)):
395
463
  time.sleep(0.1)
396
464
 
397
465
 
@@ -399,7 +467,7 @@ def format_label():
399
467
  def animated_balloons():
400
468
  widgets = ['Balloon: ', progressbar.AnimatedMarker(markers='.oO@* ')]
401
469
  bar = progressbar.ProgressBar(widgets=widgets)
402
- for i in bar((i for i in range(24))):
470
+ for _ in bar(i for i in range(24)):
403
471
  time.sleep(0.1)
404
472
 
405
473
 
@@ -409,7 +477,7 @@ def animated_arrows():
409
477
  try:
410
478
  widgets = ['Arrows: ', progressbar.AnimatedMarker(markers='←↖↑↗→↘↓↙')]
411
479
  bar = progressbar.ProgressBar(widgets=widgets)
412
- for i in bar((i for i in range(24))):
480
+ for _ in bar(i for i in range(24)):
413
481
  time.sleep(0.1)
414
482
  except UnicodeError:
415
483
  sys.stdout.write('Unicode error: skipping example')
@@ -421,7 +489,7 @@ def animated_filled_arrows():
421
489
  try:
422
490
  widgets = ['Arrows: ', progressbar.AnimatedMarker(markers='◢◣◤◥')]
423
491
  bar = progressbar.ProgressBar(widgets=widgets)
424
- for i in bar((i for i in range(24))):
492
+ for _ in bar(i for i in range(24)):
425
493
  time.sleep(0.1)
426
494
  except UnicodeError:
427
495
  sys.stdout.write('Unicode error: skipping example')
@@ -433,7 +501,7 @@ def animated_wheels():
433
501
  try:
434
502
  widgets = ['Wheels: ', progressbar.AnimatedMarker(markers='◐◓◑◒')]
435
503
  bar = progressbar.ProgressBar(widgets=widgets)
436
- for i in bar((i for i in range(24))):
504
+ for _ in bar(i for i in range(24)):
437
505
  time.sleep(0.1)
438
506
  except UnicodeError:
439
507
  sys.stdout.write('Unicode error: skipping example')
@@ -446,7 +514,7 @@ def format_label_bouncer():
446
514
  progressbar.BouncingBar(),
447
515
  ]
448
516
  bar = progressbar.ProgressBar(widgets=widgets)
449
- for i in bar((i for i in range(100))):
517
+ for _ in bar(i for i in range(100)):
450
518
  time.sleep(0.01)
451
519
 
452
520
 
@@ -458,14 +526,14 @@ def format_label_rotating_bouncer():
458
526
  ]
459
527
 
460
528
  bar = progressbar.ProgressBar(widgets=widgets)
461
- for i in bar((i for i in range(18))):
529
+ for _ in bar(i for i in range(18)):
462
530
  time.sleep(0.1)
463
531
 
464
532
 
465
533
  @example
466
534
  def with_right_justify():
467
535
  with progressbar.ProgressBar(
468
- max_value=10, term_width=20, left_justify=False
536
+ max_value=10, term_width=20, left_justify=False
469
537
  ) as progress:
470
538
  assert progress.term_width is not None
471
539
  for i in range(10):
@@ -474,20 +542,16 @@ def with_right_justify():
474
542
 
475
543
  @example
476
544
  def exceeding_maximum():
477
- with progressbar.ProgressBar(max_value=1) as progress:
478
- try:
479
- progress.update(2)
480
- except ValueError:
481
- pass
545
+ with progressbar.ProgressBar(max_value=1) as progress, contextlib.suppress(
546
+ ValueError):
547
+ progress.update(2)
482
548
 
483
549
 
484
550
  @example
485
551
  def reaching_maximum():
486
552
  progress = progressbar.ProgressBar(max_value=1)
487
- try:
553
+ with contextlib.suppress(RuntimeError):
488
554
  progress.update(1)
489
- except RuntimeError:
490
- pass
491
555
 
492
556
 
493
557
  @example
@@ -504,20 +568,11 @@ def stderr_redirection():
504
568
  progress.update(0)
505
569
 
506
570
 
507
- @example
508
- def negative_maximum():
509
- try:
510
- with progressbar.ProgressBar(max_value=-1) as progress:
511
- progress.start()
512
- except ValueError:
513
- pass
514
-
515
-
516
571
  @example
517
572
  def rotating_bouncing_marker():
518
573
  widgets = [progressbar.BouncingBar(marker=progressbar.RotatingMarker())]
519
574
  with progressbar.ProgressBar(
520
- widgets=widgets, max_value=20, term_width=10
575
+ widgets=widgets, max_value=20, term_width=10
521
576
  ) as progress:
522
577
  for i in range(20):
523
578
  time.sleep(0.1)
@@ -529,7 +584,7 @@ def rotating_bouncing_marker():
529
584
  )
530
585
  ]
531
586
  with progressbar.ProgressBar(
532
- widgets=widgets, max_value=20, term_width=10
587
+ widgets=widgets, max_value=20, term_width=10
533
588
  ) as progress:
534
589
  for i in range(20):
535
590
  time.sleep(0.1)
@@ -545,7 +600,7 @@ def incrementing_bar():
545
600
  ],
546
601
  max_value=10,
547
602
  ).start()
548
- for i in range(10):
603
+ for _ in range(10):
549
604
  # do something
550
605
  time.sleep(0.1)
551
606
  bar += 1
@@ -581,13 +636,17 @@ def eta_types_demonstration():
581
636
  progressbar.Percentage(),
582
637
  ' ETA: ',
583
638
  progressbar.ETA(),
584
- ' Adaptive ETA: ',
639
+ ' Adaptive : ',
585
640
  progressbar.AdaptiveETA(),
586
- ' Absolute ETA: ',
641
+ ' Smoothing(a=0.1): ',
642
+ progressbar.SmoothingETA(smoothing_parameters=dict(alpha=0.1)),
643
+ ' Smoothing(a=0.9): ',
644
+ progressbar.SmoothingETA(smoothing_parameters=dict(alpha=0.9)),
645
+ ' Absolute: ',
587
646
  progressbar.AbsoluteETA(),
588
- ' Transfer Speed: ',
647
+ ' Transfer: ',
589
648
  progressbar.FileTransferSpeed(),
590
- ' Adaptive Transfer Speed: ',
649
+ ' Adaptive T: ',
591
650
  progressbar.AdaptiveTransferSpeed(),
592
651
  ' ',
593
652
  progressbar.Bar(),
@@ -617,7 +676,7 @@ def adaptive_eta_without_value_change():
617
676
  poll_interval=0.0001,
618
677
  )
619
678
  bar.start()
620
- for i in range(100):
679
+ for _ in range(100):
621
680
  bar.update(1)
622
681
  time.sleep(0.1)
623
682
  bar.finish()
@@ -628,9 +687,9 @@ def iterator_with_max_value():
628
687
  # Testing using progressbar as an iterator with a max value
629
688
  bar = progressbar.ProgressBar()
630
689
 
631
- for n in bar(iter(range(100)), 100):
690
+ for _ in bar(iter(range(100)), 100):
632
691
  # iter range is a way to get an iterator in both python 2 and 3
633
- pass
692
+ time.sleep(0.01)
634
693
 
635
694
 
636
695
  @example
@@ -698,13 +757,13 @@ def user_variables():
698
757
  num_subtasks = sum(len(x) for x in tasks.values())
699
758
 
700
759
  with progressbar.ProgressBar(
701
- prefix='{variables.task} >> {variables.subtask}',
702
- variables={'task': '--', 'subtask': '--'},
703
- max_value=10 * num_subtasks,
760
+ prefix='{variables.task} >> {variables.subtask}',
761
+ variables={'task': '--', 'subtask': '--'},
762
+ max_value=10 * num_subtasks,
704
763
  ) as bar:
705
764
  for tasks_name, subtasks in tasks.items():
706
765
  for subtask_name in subtasks:
707
- for i in range(10):
766
+ for _ in range(10):
708
767
  bar.update(
709
768
  bar.value + 1, task=tasks_name, subtask=subtask_name
710
769
  )
@@ -736,14 +795,14 @@ def format_custom_text():
736
795
  @example
737
796
  def simple_api_example():
738
797
  bar = progressbar.ProgressBar(widget_kwargs=dict(fill='█'))
739
- for i in bar(range(200)):
798
+ for _ in bar(range(200)):
740
799
  time.sleep(0.02)
741
800
 
742
801
 
743
802
  @example
744
- def ETA_on_generators():
803
+ def eta_on_generators():
745
804
  def gen():
746
- for x in range(200):
805
+ for _ in range(200):
747
806
  yield None
748
807
 
749
808
  widgets = [
@@ -755,14 +814,14 @@ def ETA_on_generators():
755
814
  ]
756
815
 
757
816
  bar = progressbar.ProgressBar(widgets=widgets)
758
- for i in bar(gen()):
817
+ for _ in bar(gen()):
759
818
  time.sleep(0.02)
760
819
 
761
820
 
762
821
  @example
763
822
  def percentage_on_generators():
764
823
  def gen():
765
- for x in range(200):
824
+ for _ in range(200):
766
825
  yield None
767
826
 
768
827
  widgets = [
@@ -775,19 +834,22 @@ def percentage_on_generators():
775
834
  ]
776
835
 
777
836
  bar = progressbar.ProgressBar(widgets=widgets)
778
- for i in bar(gen()):
837
+ for _ in bar(gen()):
779
838
  time.sleep(0.02)
780
839
 
781
840
 
782
841
  def test(*tests):
783
842
  if tests:
843
+ no_tests = True
784
844
  for example in examples:
785
845
  for test in tests:
786
846
  if test in example.__name__:
787
847
  example()
848
+ no_tests = False
788
849
  break
789
850
 
790
- else:
851
+ if no_tests:
852
+ for example in examples:
791
853
  print('Skipping', example.__name__)
792
854
  else:
793
855
  for example in examples:
@@ -21,7 +21,7 @@ long running operations.
21
21
  '''.strip().split(),
22
22
  )
23
23
  __email__ = 'wolph@wol.ph'
24
- __version__ = '4.3.2'
24
+ __version__ = '4.4.1'
25
25
  __license__ = 'BSD'
26
26
  __copyright__ = 'Copyright 2015 Rick van Hattem (Wolph)'
27
27
  __url__ = 'https://github.com/WoLpH/python-progressbar'
@@ -1,6 +1,11 @@
1
1
  from datetime import date
2
2
 
3
3
  from .__about__ import __author__, __version__
4
+ from .algorithms import (
5
+ DoubleExponentialMovingAverage,
6
+ ExponentialMovingAverage,
7
+ SmoothingAlgorithm,
8
+ )
4
9
  from .bar import DataTransferBar, NullBar, ProgressBar
5
10
  from .base import UnknownLength
6
11
  from .multi import MultiBar, SortKey
@@ -32,6 +37,7 @@ from .widgets import (
32
37
  ReverseBar,
33
38
  RotatingMarker,
34
39
  SimpleProgress,
40
+ SmoothingETA,
35
41
  Timer,
36
42
  Variable,
37
43
  VariableMixin,
@@ -46,6 +52,10 @@ __all__ = [
46
52
  'ETA',
47
53
  'AdaptiveETA',
48
54
  'AbsoluteETA',
55
+ 'SmoothingETA',
56
+ 'SmoothingAlgorithm',
57
+ 'ExponentialMovingAverage',
58
+ 'DoubleExponentialMovingAverage',
49
59
  'DataSize',
50
60
  'FileTransferSpeed',
51
61
  'AdaptiveTransferSpeed',