Skip to content

Commit

Permalink
Merge pull request #7840 from xavfernandez/revert_progress_bar_format…
Browse files Browse the repository at this point in the history
…_change

cli: revert format() related changes
  • Loading branch information
pradyunsg authored Mar 10, 2020
2 parents 4d1932f + a096d4c commit e15ef59
Showing 1 changed file with 15 additions and 18 deletions.
33 changes: 15 additions & 18 deletions src/pip/_internal/cli/progress_bars.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from pip._internal.utils.typing import MYPY_CHECK_RUNNING

if MYPY_CHECK_RUNNING:
from typing import Any, Dict, Iterator, List, Tuple
from typing import Any, Dict, List

try:
from pip._vendor import colorama
Expand Down Expand Up @@ -124,7 +124,7 @@ def update(self):

class BlueEmojiBar(IncrementalBar):

suffix = "{percent:.0f}%"
suffix = "%(percent)d%%"
bar_prefix = " "
bar_suffix = " "
phases = (u"\U0001F539", u"\U0001F537", u"\U0001F535") # type: Any
Expand Down Expand Up @@ -203,8 +203,8 @@ class BaseDownloadProgressBar(WindowsMixin, InterruptibleMixin,
DownloadProgressMixin):

file = sys.stdout
message = "{percent:.0f}%"
suffix = "{downloaded} {download_speed} {pretty_eta}"
message = "%(percent)d%%"
suffix = "%(downloaded)s %(download_speed)s %(pretty_eta)s"

# NOTE: The "type: ignore" comments on the following classes are there to
# work around https://github.com/python/typing/issues/241
Expand Down Expand Up @@ -238,7 +238,7 @@ class DownloadProgressSpinner(WindowsMixin, InterruptibleMixin,
DownloadProgressMixin, Spinner):

file = sys.stdout
suffix = "{downloaded} {download_speed}"
suffix = "%(downloaded)s %(download_speed)s"

def next_phase(self): # type: ignore
if not hasattr(self, "_phaser"):
Expand All @@ -247,21 +247,18 @@ def next_phase(self): # type: ignore

def update(self):
# type: () -> None
vals = dict(self._load_vals(
'downloaded', 'download_speed', 'pretty_eta', 'percent'))
message = self.message.format(**vals)
message = self.message % self
phase = self.next_phase()
suffix = self.suffix.format(**vals)
line = " ".join(filter(None, (message, phase, suffix)))
self.writeln(line)
suffix = self.suffix % self
line = ''.join([
message,
" " if message else "",
phase,
" " if suffix else "",
suffix,
])

def _load_vals(self, *names):
# type: (*str) -> Iterator[Tuple[str, Any]]
for name in names:
try:
yield name, getattr(self, name)
except Exception:
pass
self.writeln(line)


BAR_TYPES = {
Expand Down

0 comments on commit e15ef59

Please sign in to comment.