From b45f87453651a93ed3b718deee1a704628faec70 Mon Sep 17 00:00:00 2001 From: Scott Percival Date: Mon, 23 Dec 2024 11:02:04 +0800 Subject: [PATCH] Fix progress bar code to support progressbar2 --- osc/meter.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/osc/meter.py b/osc/meter.py index 4e6a7c230..466a58186 100644 --- a/osc/meter.py +++ b/osc/meter.py @@ -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 @@ -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()