Skip to content

Commit 6b79ecc

Browse files
committed
Merge branch 'release/4.1.0'
2 parents fcbf77b + 57a4a65 commit 6b79ecc

File tree

7 files changed

+78
-7
lines changed

7 files changed

+78
-7
lines changed

.coveragerc

+1
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,4 @@ exclude_lines =
2222
raise NotImplementedError
2323
if 0:
2424
if __name__ == .__main__.:
25+
if types.TYPE_CHECKING:

.github/workflows/main.yml

+3-4
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,13 @@ jobs:
1414
python-version: ['3.7', '3.8', '3.9', '3.10']
1515

1616
steps:
17-
- uses: actions/checkout@v2
17+
- uses: actions/checkout@v3
1818
- name: Set up Python ${{ matrix.python-version }}
19-
uses: actions/setup-python@v2
19+
uses: actions/setup-python@v4
2020
with:
2121
python-version: ${{ matrix.python-version }}
2222
- name: Install dependencies
2323
run: |
24-
python -m pip install --upgrade pip
25-
pip install tox tox-gh-actions
24+
python -m pip install --upgrade pip tox
2625
- name: Test with tox
2726
run: tox

README.rst

+65
Original file line numberDiff line numberDiff line change
@@ -237,3 +237,68 @@ Bar with wide Chinese (or other multibyte) characters
237237
)
238238
for i in bar(range(10)):
239239
time.sleep(0.1)
240+
241+
Showing multiple (threaded) independent progress bars in parallel
242+
==============================================================================
243+
244+
While this method works fine and will continue to work fine, a smarter and
245+
fully automatic version of this is currently being made:
246+
https://github.com/WoLpH/python-progressbar/issues/176
247+
248+
.. code:: python
249+
250+
import random
251+
import sys
252+
import threading
253+
import time
254+
255+
import progressbar
256+
257+
output_lock = threading.Lock()
258+
259+
260+
class LineOffsetStreamWrapper:
261+
UP = '\033[F'
262+
DOWN = '\033[B'
263+
264+
def __init__(self, lines=0, stream=sys.stderr):
265+
self.stream = stream
266+
self.lines = lines
267+
268+
def write(self, data):
269+
with output_lock:
270+
self.stream.write(self.UP * self.lines)
271+
self.stream.write(data)
272+
self.stream.write(self.DOWN * self.lines)
273+
self.stream.flush()
274+
275+
def __getattr__(self, name):
276+
return getattr(self.stream, name)
277+
278+
279+
bars = []
280+
for i in range(5):
281+
bars.append(
282+
progressbar.ProgressBar(
283+
fd=LineOffsetStreamWrapper(i),
284+
max_value=1000,
285+
)
286+
)
287+
288+
if i:
289+
print('Reserve a line for the progressbar')
290+
291+
292+
class Worker(threading.Thread):
293+
def __init__(self, bar):
294+
super().__init__()
295+
self.bar = bar
296+
297+
def run(self):
298+
for i in range(1000):
299+
time.sleep(random.random() / 100)
300+
self.bar.update(i)
301+
302+
303+
for bar in bars:
304+
Worker(bar).start()

progressbar/__about__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
long running operations.
2020
'''.strip().split())
2121
__email__ = '[email protected]'
22-
__version__ = '4.0.0'
22+
__version__ = '4.1.0'
2323
__license__ = 'BSD'
2424
__copyright__ = 'Copyright 2015 Rick van Hattem (Wolph)'
2525
__url__ = 'https://github.com/WoLpH/python-progressbar'

progressbar/py.typed

Whitespace-only changes.

progressbar/utils.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,8 @@ def __init__(self, target: types.IO, capturing: bool = False,
199199
self.listeners = listeners or set()
200200
self.needs_clear = False
201201

202-
def isatty(self): # pragma: no cover
203-
return self.target.isatty()
202+
def __getattr__(self, name): # pragma: no cover
203+
return getattr(self.target, name)
204204

205205
def write(self, value: str) -> None:
206206
if self.capturing:

tox.ini

+6
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ basepython = python3
2121
deps = flake8
2222
commands = flake8 {toxinidir}/progressbar {toxinidir}/tests {toxinidir}/examples.py
2323

24+
[testenv:pyright]
25+
changedir =
26+
basepython = python3
27+
deps = pyright
28+
commands = pyright {toxinidir}/progressbar
29+
2430
[testenv:docs]
2531
changedir =
2632
basepython = python3

0 commit comments

Comments
 (0)