remove old progress

- progress.Progress
- progress.ProgressCallback
- progress.progress
This commit is contained in:
Casper da Costa-Luis
2019-08-10 14:19:38 +01:00
parent 82bb550e7d
commit d6f816bc48
-71
View File
@@ -63,74 +63,3 @@ class Tqdm(tqdm):
return fill[-max_len:] if end else fill[:max_len]
i = max_len - len(fill)
return (fill + s[-i:]) if end else (s[:i] + fill)
class Progress(tqdm):
"""
Simple multi-target progress bar.
TODO: remove this class.
"""
def __init__(self):
super(Progress, self).__init__(total=0, disable=True)
from time import time
self._time = time
self.set_lock(Lock())
self._targets = {}
self.clearln()
def set_n_total(self, total):
"""Sets total number of targets."""
self.reset(total)
@property
def is_finished(self):
"""Returns if all targets have finished."""
return self.total == self.n
def clearln(self):
pass
def update_target(self, name, current, total, auto_finish=False):
"""Updates progress bar for a specified target."""
if total and self.total != total:
self.set_n_total(total)
self.set_postfix_str(name, refresh=False)
self.update(current - self.n)
if auto_finish and self.is_finished:
self.finish_target(name)
def finish_target(self, name):
"""Finishes progress bar for a specified target."""
# TODO: We have to write a msg about finished target
self.set_postfix_str(name, refresh=False)
self.clearln()
def __call__(self, seq, name="", total=None):
logger = logging.getLogger(__name__)
logger.warning("DeprecationWarning: create Tqdm() instance instead")
if total is None:
total = len(seq)
self.update_target(name, 0, total)
for done, item in enumerate(seq, start=1):
yield item
self.update_target(name, done, total)
self.finish_target(name)
class ProgressCallback(object):
# TODO: remove this thin wrapper
def __init__(self, total):
self.total = total
self.current = 0
progress.reset()
def update(self, name, progress_to_add=1):
self.current += progress_to_add
progress.update_target(name, self.current, self.total)
def finish(self, name):
progress.finish_target(name)
progress = Progress() # pylint: disable=invalid-name