@@ -68,7 +68,7 @@ def write_line(self, line: str):
6868
6969 Ignores empty lines.
7070 """
71- if ( type ( line ) == str ) and line .strip ():
71+ if isinstance ( line , str ) and line .strip ():
7272 self ._box .content .controls [0 ].value += f"\n >{ line .strip ()} "
7373 self ._box .content .controls [0 ].value = self ._box .content .controls [
7474 0
@@ -115,7 +115,7 @@ def display_progress_bar(self, line: str):
115115 percentage_done = None
116116 result = None
117117 # create the progress bar
118- if self .progress_bar == None :
118+ if not self .progress_bar :
119119 self .progress_bar = ProgressBar (
120120 value = 1 / 100 ,
121121 width = 500 ,
@@ -129,7 +129,7 @@ def display_progress_bar(self, line: str):
129129 Row ([self .percentage_text , self .progress_bar ])
130130 )
131131 # get the progress numbers from the output lines
132- if ( type ( line ) == str ) and line .strip ():
132+ if isinstance ( line , str ) and line .strip ():
133133 result = re .search (
134134 r"\(\~(\d{1,3})\%\)|(Total xfer:|adb: failed to read command: Success)" ,
135135 line .strip (),
@@ -139,10 +139,7 @@ def display_progress_bar(self, line: str):
139139 percentage_done = 99
140140 elif result .group (1 ):
141141 percentage_done = int (result .group (1 ))
142- if percentage_done == 0 :
143- percentage_done = 1
144- elif percentage_done == 100 :
145- percentage_done = 99
142+ percentage_done = max (1 , min (99 , percentage_done ))
146143
147144 # update the progress bar
148145 self .set_progress_bar (percentage_done )
0 commit comments