Merge pull request #7840 from xavfernandez/revert_progress_bar_format_change

cli: revert format() related changes
This commit is contained in:
Pradyun Gedam 2020-03-11 01:36:31 +05:30 committed by GitHub
commit e15ef595dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 18 deletions

View File

@ -14,7 +14,7 @@ from pip._internal.utils.misc import format_size
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
@ -124,7 +124,7 @@ class SilentBar(Bar):
class BlueEmojiBar(IncrementalBar):
suffix = "{percent:.0f}%"
suffix = "%(percent)d%%"
bar_prefix = " "
bar_suffix = " "
phases = (u"\U0001F539", u"\U0001F537", u"\U0001F535") # type: Any
@ -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
@ -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"):
@ -247,21 +247,18 @@ class DownloadProgressSpinner(WindowsMixin, InterruptibleMixin,
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 = {