def print_progress(self, threshold=0, decimals=1, barLength=100):
"""Print a terminal progress bar."""
# Based on @Greenstick's reply (https://stackoverflow.com/a/34325723)
iteration = self.stream.tell()
if iteration > self.file_size:
return
total = self.file_size
if total == 0:
return
progress = 100.0 * iteration / total
if self.progress and progress - self.progress < threshold:
return
self.progress = progress
percents = ("%03." + str(decimals) + "f") % progress
filledLength = int(round(barLength * iteration / float(total)))
barText = '*' * filledLength + '-' * (barLength - filledLength)
stdout.write('%s| %s%% Completed\r' % (barText, percents))
stdout.flush()
inputdevices.py 文件源码
python
阅读 24
收藏 0
点赞 0
评论 0
评论列表
文章目录