Coverage for /usr/local/lib/python3.11/dist-packages/pyrocko/dummy_progressbar.py: 85%
34 statements
« prev ^ index » next coverage.py v6.5.0, created at 2023-10-06 15:01 +0000
« prev ^ index » next coverage.py v6.5.0, created at 2023-10-06 15:01 +0000
1# http://pyrocko.org - GPLv3
2#
3# The Pyrocko Developers, 21st Century
4# ---|P------/S----------~Lg----------
6'''
7Progressbar replacement class which just outputs progress to log.
8'''
10import time
11import logging
14logger = logging.getLogger('pyrocko.progress')
17class ProgressBar(object):
18 def __init__(self, widgets=['progress'], maxval=1, *args, **kwargs):
19 self._widgets = widgets
20 self._maxval = maxval
21 self._val = 0
22 self._time = time.time()
24 def label(self):
25 for widget in self._widgets:
26 if isinstance(widget, str):
27 return widget
29 def start(self):
30 logger.info('%s...' % self.label())
31 return self
33 def update(self, val):
34 self._val = val
35 t = time.time()
36 if t - self._time > 5.0:
37 logger.info('%s: %i/%i %3.0f%%' % (
38 self.label(),
39 self._val,
40 self._maxval,
41 100.*float(self._val) / float(self._maxval)))
43 self._time = t
45 def finish(self):
46 logger.info('%s: done.' % self.label())
49class Bar(object):
50 def __init__(self, *args, **kwargs):
51 pass
54class Percentage(object):
55 def __init__(self, *args, **kwargs):
56 pass
59class ETA(object):
60 def __init__(self, *args, **kwargs):
61 pass