@@ -58,7 +58,7 @@ def update(self, new_done, symbol = '*', getSuffix = None):
5858 suffix = getSuffix (new_done , progress )
5959 msg_and_bar_width = terminal_width - len (suffix )
6060 msg_width = min (len (self .msg ), int (msg_and_bar_width / 2 ))
61- msg_to_print = self .msg [: msg_width ]
61+ msg_to_print = self .msg [- msg_width : ]
6262 bar_width = msg_and_bar_width - msg_width
6363 if bar_width < self .MIN_BAR_WIDTH :
6464 bar_width = terminal_width - 2
@@ -78,8 +78,9 @@ def acc(self):
7878 def complete (self ):
7979 def getSuffix (done , progress ):
8080 return 'Complete! Total: %d' % self .goal
81- self .update (self .goal ) , symbol = '#' , getSuffix = getSuffix )
81+ self .update (self .goal , symbol = '#' , getSuffix = getSuffix )
8282 self .active = False
83+ print ()
8384
8485class CommJdt (Jdt ):
8586 def __init__ (self , * argv , ** kw ):
@@ -97,7 +98,7 @@ def update(self, new_done, *argv, **kw):
9798 speed = delta_done / delta_time
9899 def getSuffix (done , progress ):
99100 nonlocal speed
100- return '%s Total: %s Done: %s Speed: %s' % (
101+ return '%s Total: %s Done: %s Speed: %s/s ' % (
101102 format (progress , '4.0%' ),
102103 smartUnit (self .goal ),
103104 smartUnit (done ),
@@ -108,9 +109,14 @@ def getSuffix(done, progress):
108109
109110if __name__ == '__main__' :
110111 from time import sleep
111- j = CommJdt (10240000 )
112+ j = CommJdt (10240000 , '/sdcard/download/browser/file.jpg' )
112113 for i in range (0 ,10240000 ,32345 ):
113114 j .update (i )
114115 sleep (0.01 )
115116 j .complete ()
117+ j = Jdt (500 , 'launching game' )
118+ for i in range (500 ):
119+ j .acc ()
120+ sleep (0.01 )
121+ j .complete ()
116122 input ('Enter..' )
0 commit comments