Make the progress bar percentage indicator stop at 100% instead of just 99%.
authorZac Medico <zmedico@gentoo.org>
Wed, 20 Jun 2007 10:06:30 +0000 (10:06 -0000)
committerZac Medico <zmedico@gentoo.org>
Wed, 20 Jun 2007 10:06:30 +0000 (10:06 -0000)
svn path=/main/trunk/; revision=6889

pym/portage/output.py

index 847e5627a5e30ca23f7d9f3b7b0f417d67173725..010c0472f0445700e3cba4d1be93ca57e4a920e8 100644 (file)
@@ -523,9 +523,11 @@ class TermProgressBar(ProgressBar):
                curval = self._curval
                maxval = self._maxval
                position = self._position
-               if cols < 3:
+               percentage_str_width = 4
+               square_brackets_width = 2
+               if cols < percentage_str_width:
                        return ""
-               bar_space = cols - 6
+               bar_space = cols - percentage_str_width - square_brackets_width
                if maxval == 0:
                        max_bar_width = bar_space-3
                        image = "    "
@@ -550,11 +552,12 @@ class TermProgressBar(ProgressBar):
                                "<=>" + ((max_bar_width - bar_width) * " ") + "]"
                        return image
                else:
-                       max_bar_width = bar_space-1
                        percentage = int(100 * float(curval) / maxval)
                        if percentage == 100:
-                               percentage = 99
-                       image = ("%d%% " % percentage).rjust(4)
+                               percentage_str_width += 1
+                               bar_space -= 1
+                       max_bar_width = bar_space - 1
+                       image = ("%d%% " % percentage).rjust(percentage_str_width)
                        if cols < min_columns:
                                return image
                        offset = float(curval) / maxval