MCPcopy Create free account
hub / github.com/Jack-Cherish/python-spider / ProgressBar

Class ProgressBar

downloader.py:5–30  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3from contextlib import closing
4
5class ProgressBar(object):
6 def __init__(self, title, count=0.0, run_status=None, fin_status=None, total=100.0, unit='', sep='/', chunk_size=1.0):
7 super(ProgressBar, self).__init__()
8 self.info = "[%s] %s %.2f %s %s %.2f %s"
9 self.title = title
10 self.total = total
11 self.count = count
12 self.chunk_size = chunk_size
13 self.status = run_status or ""
14 self.fin_status = fin_status or " " * len(self.status)
15 self.unit = unit
16 self.seq = sep
17
18 def __get_info(self):
19 #[名称] 状态 进度 单位 分割线 总数 单位
20 _info = self.info % (self.title, self.status, self.count/self.chunk_size, self.unit, self.seq, self.total/self.chunk_size, self.unit)
21 return _info
22
23 def refresh(self, count = 1, status = None):
24 self.count += count
25 self.status = status or self.status
26 end_str = "\r"
27 if self.count >= self.total:
28 end_str = '\n'
29 self.status = status or self.fin_status
30 print(self.__get_info(), end=end_str, )
31
32
33if __name__ == '__main__':

Callers 1

downloader.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected