mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-09 23:10:24 +01:00
cleanup: remove junk file
Added by mistake. Signed-off-by: Ruslan Kuprieiev <[email protected]>
This commit is contained in:
@@ -1,90 +0,0 @@
|
||||
from __future__ import print_function
|
||||
import sys
|
||||
import threading
|
||||
from Queue import Queue
|
||||
|
||||
# (2/100): very_long_nam... [######### ] 60%
|
||||
|
||||
class ProgressInfo(object):
|
||||
name = ""
|
||||
current = 0
|
||||
total = None
|
||||
finished = False
|
||||
|
||||
class Progress(object):
|
||||
_n_finished = 0
|
||||
_n_total = 0
|
||||
_lock = None
|
||||
_queue = None
|
||||
|
||||
def __init__(self, total):
|
||||
self._n_total = total
|
||||
self._lock = threading.Lock()
|
||||
self._queue = Queue(maxsize=0)
|
||||
|
||||
def clearln(self):
|
||||
if sys.stdout.isatty():
|
||||
print('\r\x1b[K', end='')
|
||||
|
||||
def writeln(self, line):
|
||||
if sys.stdout.isatty():
|
||||
self.clearln()
|
||||
print(line, end='')
|
||||
sys.stdout.flush()
|
||||
|
||||
def update_target(self, name, current, total):
|
||||
info = ProgressInfo()
|
||||
info.name = name
|
||||
info.current = current
|
||||
info.total = total
|
||||
|
||||
self._queue.put(info)
|
||||
|
||||
def finish_target(self, name):
|
||||
info = ProgressInfo()
|
||||
info.name = name
|
||||
info.current = 100
|
||||
info.total = 100
|
||||
info.finished = True
|
||||
|
||||
self._queue.put(info)
|
||||
|
||||
def finish(self):
|
||||
if sys.stdout.isatty():
|
||||
print()
|
||||
|
||||
def _bar(self, info):
|
||||
total_len = 80
|
||||
bar_len = 40
|
||||
|
||||
if info.total == None:
|
||||
progress = 0
|
||||
percent = "?% "
|
||||
else:
|
||||
progress = (100 * info.current)/info.total
|
||||
percent = str(progress) + "% "
|
||||
|
||||
num = "({}/{}): ".format(self._n_finished + 1, self._n_total)
|
||||
|
||||
n_sh = (progress * bar_len)/100
|
||||
n_sp = bar_len - n_sh
|
||||
bar = "[" + '#'*n_sh + ' '*n_sp + "] "
|
||||
|
||||
name_len = len(num + bar + percent) + 1
|
||||
name = info.name[:name_len] if len(info.name) > name_len else info.name
|
||||
|
||||
return num + bar + percent + name
|
||||
|
||||
def wait(self):
|
||||
while self._n_finished != self._n_total:
|
||||
while not self._queue.empty():
|
||||
info = self._queue.get()
|
||||
bar = self._bar(info)
|
||||
with self._lock:
|
||||
if info.finished:
|
||||
self.clearln()
|
||||
print(bar)
|
||||
self._n_finished += 1
|
||||
else:
|
||||
self.writeln(bar)
|
||||
self.finish()
|
||||
Reference in New Issue
Block a user