mirror of
https://github.com/pypa/pip
synced 2023-12-13 21:30:23 +01:00
Fix issue where format_map isn't available on Python 2
This commit is contained in:
parent
6282a307dc
commit
def75dc691
|
@ -14,7 +14,7 @@ from pip._internal.utils.misc import format_size
|
||||||
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
|
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
|
||||||
|
|
||||||
if MYPY_CHECK_RUNNING:
|
if MYPY_CHECK_RUNNING:
|
||||||
from typing import Any, Dict, List
|
from typing import Any, Dict, Iterator, List, Tuple
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from pip._vendor import colorama
|
from pip._vendor import colorama
|
||||||
|
@ -247,18 +247,22 @@ class DownloadProgressSpinner(WindowsMixin, InterruptibleMixin,
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
# type: () -> None
|
# type: () -> None
|
||||||
vals = dict(
|
vals = dict(self._load_vals(
|
||||||
downloaded=self.downloaded,
|
'downloaded', 'download_speed', 'pretty_eta', 'percent'))
|
||||||
download_speed=self.download_speed,
|
|
||||||
pretty_eta=self.pretty_eta,
|
|
||||||
percent=self.percent,
|
|
||||||
)
|
|
||||||
message = self.message.format(**vals)
|
message = self.message.format(**vals)
|
||||||
phase = self.next_phase()
|
phase = self.next_phase()
|
||||||
suffix = self.suffix.format(**vals)
|
suffix = self.suffix.format(**vals)
|
||||||
line = " ".join(filter(None, (message, phase, suffix)))
|
line = " ".join(filter(None, (message, phase, suffix)))
|
||||||
self.writeln(line)
|
self.writeln(line)
|
||||||
|
|
||||||
|
def _load_vals(self, *names):
|
||||||
|
# type: (*str) -> Iterator[Tuple[str, Any]]
|
||||||
|
for name in names:
|
||||||
|
try:
|
||||||
|
yield name, getattr(self, name)
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
BAR_TYPES = {
|
BAR_TYPES = {
|
||||||
"off": (DownloadSilentBar, DownloadSilentBar),
|
"off": (DownloadSilentBar, DownloadSilentBar),
|
||||||
|
|
Loading…
Reference in a new issue