1
0
mirror of https://github.com/openSUSE/osc.git synced 2025-08-20 05:28:53 +02:00

reworked meter.py based on discussion

* new function create_text_meter with fallback selection
* NoPBTextMeter.start() will print the basename (if not stated otherise with
  basename = None)
* The callers that should use an alternare TextMeter class now call create_text_meter()
* The callers that should not use and alternate TextMeter (because of different handling,
  like build.py) call create_text_meter(use_pb_fallback=False)
* the warning 'Please install the progressbar module' is now only shown once

improvements
This commit is contained in:
lethliel
2019-01-14 12:03:16 +01:00
parent e608200414
commit 93d15fc83b
5 changed files with 35 additions and 23 deletions

View File

@@ -29,8 +29,30 @@ class PBTextMeter(object):
self.bar.finish()
class NoPBTextMeter(object):
_complained = False
def start(self, basename, size=None):
if not self._complained:
print('Please install the progressbar module')
NoPBTextMeter._complained = True
print('Processing: %s' % basename)
def update(self, *args, **kwargs):
pass
def end(self, *args, **kwargs):
pass
def create_text_meter(*args, **kwargs):
use_pb_fallback = kwargs.pop('use_pb_fallback', True)
if have_pb_module or use_pb_fallback:
return TextMeter(*args, **kwargs)
return None
if have_pb_module:
TextMeter = PBTextMeter
else:
TextMeter = None
TextMeter = NoPBTextMeter
# vim: sw=4 et