Skip to content

Commit

Permalink
Fix progress bar code to support progressbar2
Browse files Browse the repository at this point in the history
  • Loading branch information
scottp-dpaw committed Dec 23, 2024
1 parent ffca873 commit b45f874
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions osc/meter.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
try:
import progressbar as pb
have_pb_module = True
using_pb_progressbar2 = tuple(map(int, pb.__version__.split('.'))) >= (3, 1)
except ImportError:
have_pb_module = False

Expand Down Expand Up @@ -62,9 +63,14 @@ def end(self):
for i in self.bar.widgets:
if not isinstance(i, pb.Bar):
continue
i.marker = " "
i.left = " "
i.right = " "
if using_pb_progressbar2:
i.marker = lambda _progress, _data, _width: " "
i.left = lambda _progress, _data, _width: " "
i.right = lambda _progress, _data, _width: " "
else:
i.marker = " "
i.left = " "
i.right = " "

self.bar.finish()

Expand Down

0 comments on commit b45f874

Please sign in to comment.