Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cli: revert format() related changes #7840

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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