]> git.phdru.name Git - m_lib.git/blobdiff - m_lib/pbar/tty_pbar.py
Use integer division for Py3 compatibility
[m_lib.git] / m_lib / pbar / tty_pbar.py
index 3903d1f2d4205ef53baaf0bac617a95eccb47bee..0bf4223ed3567503d5358aa7fa88eda6b5ea2bb8 100644 (file)
@@ -1,8 +1,4 @@
-"""
-   Progress bar (TTY version)
-
-   Written by Broytman, Jan 1997 - Sep 2003. Copyright (C) 1997-2003 PhiloSoft Design
-"""
+"""Progress bar (TTY version)"""
 
 
 import sys, os
@@ -60,16 +56,16 @@ class ttyProgressBar:
 
       self.current = current
       current -= self.min
-      lng = (current * self.width1) / self.max
+      lng = (current * self.width1) // self.max
 
       if current >= self.max:
          percent = 100
       else:
-         percent = (current * 100) / self.max
+         percent = (current * 100) // self.max
 
       flush = False
 
-      if self.lng <> lng:
+      if self.lng != lng:
          self.lng =  lng
          self.out.write(ttyProgressBar.back_c*(self.width1+self.width2))
          self.out.write(ttyProgressBar.left_c*lng)
@@ -77,12 +73,12 @@ class ttyProgressBar:
          self.percent = -1 # force to redraw percentage; the bug was fixed by William McVey
          flush = True
 
-      elif self.percent <> percent:
+      elif self.percent != percent:
          self.out.write(ttyProgressBar.back_c * (self.width2-1))
          flush = True
 
 
-      if self.percent <> percent:
+      if self.percent != percent:
          self.percent =  percent
          self.out.write(str(percent).rjust(3) + '%')
          flush = True