Skip to content

Commit 2fc35d7

Browse files
committed
Merge branch 'finish-dirty' into develop
2 parents caea3b3 + 7de9977 commit 2fc35d7

3 files changed

Lines changed: 17 additions & 4 deletions

File tree

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.39.0'
22+
__version__ = '3.39.1'
2323
__license__ = 'BSD'
2424
__copyright__ = 'Copyright 2015 Rick van Hattem (Wolph)'
2525
__url__ = 'https://github.com/WoLpH/python-progressbar'

progressbar/bar.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,7 @@ def start(self, max_value=None, init=True):
657657

658658
return self
659659

660-
def finish(self, end='\n'):
660+
def finish(self, end='\n', dirty=False):
661661
'''
662662
Puts the ProgressBar bar in the finished state.
663663
@@ -667,10 +667,13 @@ def finish(self, end='\n'):
667667
Args:
668668
end (str): The string to end the progressbar with, defaults to a
669669
newline
670+
dirty (bool): When True the progressbar kept the current state and
671+
won't be set to 100 percent
670672
'''
671673

672-
self.end_time = datetime.now()
673-
self.update(self.max_value, force=True)
674+
if not dirty:
675+
self.end_time = datetime.now()
676+
self.update(self.max_value, force=True)
674677

675678
StdRedirectMixin.finish(self, end=end)
676679
ResizableMixin.finish(self)

tests/test_progressbar.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,13 @@ def test_reuse():
4747
for i in range(10):
4848
bar.update(i)
4949
bar.finish()
50+
51+
52+
def test_dirty():
53+
import progressbar
54+
55+
bar = progressbar.ProgressBar()
56+
bar.start()
57+
for i in range(10):
58+
bar.update(i)
59+
bar.finish(dirty=True)

0 commit comments

Comments
 (0)