Skip to content

Commit def75dc

Browse files
committed
Fix issue where format_map isn't available on Python 2
1 parent 6282a30 commit def75dc

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

src/pip/_internal/cli/progress_bars.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
1515

1616
if MYPY_CHECK_RUNNING:
17-
from typing import Any, Dict, List
17+
from typing import Any, Dict, Iterator, List, Tuple
1818

1919
try:
2020
from pip._vendor import colorama
@@ -247,18 +247,22 @@ def next_phase(self): # type: ignore
247247

248248
def update(self):
249249
# type: () -> None
250-
vals = dict(
251-
downloaded=self.downloaded,
252-
download_speed=self.download_speed,
253-
pretty_eta=self.pretty_eta,
254-
percent=self.percent,
255-
)
250+
vals = dict(self._load_vals(
251+
'downloaded', 'download_speed', 'pretty_eta', 'percent'))
256252
message = self.message.format(**vals)
257253
phase = self.next_phase()
258254
suffix = self.suffix.format(**vals)
259255
line = " ".join(filter(None, (message, phase, suffix)))
260256
self.writeln(line)
261257

258+
def _load_vals(self, *names):
259+
# type: (*str) -> Iterator[Tuple[str, Any]]
260+
for name in names:
261+
try:
262+
yield name, getattr(self, name)
263+
except Exception:
264+
pass
265+
262266

263267
BAR_TYPES = {
264268
"off": (DownloadSilentBar, DownloadSilentBar),

0 commit comments

Comments
 (0)