def increment(self, inc_track=1024, inc_prog=1024, file_inc=True):
self.tracker += inc_track
self.progress += inc_prog
if file_inc:
while self.progress >= self.percent and self.tracker < self.size:
self.progress = self.progress - self.percent
self.tick += 1
space = self.bar_size - self.tick
total_percentage = 2 * self.tick
p_output = "[{}{}] %{}".format(p_bar * self.tick, ' ' * space, total_percentage)
sys.stdout.write(p_output)
sys.stdout.flush()
sys.stdout.write("\b" * (len(p_output)))
else:
self.tick = int((float(self.progress)/float(self.size)) * float(self.bar_size))
space = self.bar_size - self.tick
total_percentage = 2 * self.tick
p_output = "[{}{}] %{}".format(p_bar * self.tick, ' ' * space, total_percentage)
sys.stdout.write(p_output)
sys.stdout.flush()
sys.stdout.write("\b" * (len(p_output)))
评论列表
文章目录