[virt-tools-list] [PATCH 14/17] progress: Don't use black-listed name 'bar'

Radostin Stoyanov rstoyanov1 at gmail.com
Thu Oct 25 12:37:55 UTC 2018


Signed-off-by: Radostin Stoyanov <rstoyanov1 at gmail.com>
---
 virtinst/progress.py | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/virtinst/progress.py b/virtinst/progress.py
index 1ae41931..2c8bb8f3 100644
--- a/virtinst/progress.py
+++ b/virtinst/progress.py
@@ -218,11 +218,13 @@ def text_meter_total_size(size, downloaded=0):
 
 
 def _term_add_bar(tl, bar_max_length, pc):
-    blen = bar_max_length
-    bar = '='*int(blen * pc)
-    if (blen * pc) - int(blen * pc) >= 0.5:
-        bar += '-'
-    return tl.add(' [%-*.*s]' % (blen, blen, bar))
+    bar_len = bar_max_length * pc
+    ibar_len = int(bar_len)
+    progressbar = '=' * ibar_len
+    if (bar_len - ibar_len) >= 0.5:
+        progressbar += '-'
+    return tl.add(' [%-*.*s]' % (bar_max_length, bar_max_length,
+                                 progressbar))
 
 
 def _term_add_end(tl, osize, size):
-- 
2.17.2




More information about the virt-tools-list mailing list