Advertisement
Viraax

Untitled

Mar 26th, 2023
502
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.61 KB | None | 0 0
  1.     def draw_progress(self):
  2.         total = 1 if self.nb_total == 0 else self.nb_total
  3.         percent_done  = (self.nb_done / total) * 100
  4.         percent_error = (self.nb_error / total) * 100
  5.         percent_total = percent_done + percent_error
  6.         nb_done_and_error = self.nb_done + self.nb_error
  7.         ratio = (percent_total / 100) * self.progress_size
  8.         width = math.floor(ratio)
  9.         empty = self.progress_size - width - 1
  10.  
  11.         slice_char = "" if empty < 0 else self.chars[math.floor((ratio % 1) * len(self.chars))]
  12.         bar   = '[{0}{1}]'.format('█' * width + slice_char, ' ' * empty)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement