Skip to content
Snippets Groups Projects
Commit 61394cc4 authored by Vekhir's avatar Vekhir Committed by Chris Lamb
Browse files

Update to progressbar >= 3.0

When `progressbar` was forked and rewritten, several API changes were made. Those were only partially adapted here in diffoscope - due to lack of sufficient tooling to detect those differences at the time, as known compile errors were fixed.
Hence, this part of the code base didn't work for over 6 years - the updates introduced here are still compatible with the release of the rewrite as v3.0. Going further back likely isn't a concern anymore.
The two relevant commits in progressbar are https://github.com/wolph/python-progressbar/commit/12df6aec2b87f409bbe4dc1b09e82b048e3ff10d and https://github.com/wolph/python-progressbar/commit/a1fc83090e870d4136f93654cf54b581f0e0b882, which are included in 3.0.
One notable change is the removal of `self.bar.start()` in the setup. The change works, as the progressbar calls `start` automatically if there hasn't been one defined. Starting the progressbar within the setup, however, is problematic because the starting time is set there. At setup time, this time is in localtime - only later is it set to UTC yielding wrong time differences which can even be negative. Letting progressbar start the timer is therefore both more convenient and correct.
parent 70d940a2
No related branches found
No related tags found
1 merge request!135Update to progressbar >= 3.0
......@@ -214,7 +214,7 @@ class ProgressBar:
self.msg = ""
class Message(WidgetBase):
def update(self, pbar, _observer=self):
def __call__(self, progress, data, _observer=self):
msg = _observer.msg
width = 25
......@@ -232,7 +232,7 @@ class ProgressBar:
# Terminal handling after parent init since that sets self.fd
self.erase_to_eol = line_eraser(self.fd)
def _need_update(self):
def _needs_update(self):
return True
def erase_line(self):
......@@ -241,8 +241,7 @@ class ProgressBar:
self.fd.flush()
def finish(self):
self.finished = True
self.update(self.maxval)
super().finish()
# Clear the progress bar after completion
self.erase_line()
if self.signal_set:
......@@ -261,14 +260,12 @@ class ProgressBar:
" ",
)
)
self.bar.start()
def notify(self, current, total, msg):
self.msg = msg
self.bar.maxval = total
self.bar.value = current
self.bar.update()
self.bar.max_value = total
self.bar.update(current)
def finish(self):
self.bar.finish()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment