Skip to content

Commit 04cd2ff

Browse files
authored
Merge pull request pypa#256 from tqdm/tqdm-update
update and tweak tqdm progressbar
2 parents 43f1505 + 3b76685 commit 04cd2ff

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ ignore =
88

99
[metadata]
1010
requires-dist =
11-
tqdm >= 4.11
11+
tqdm >= 4.14
1212
requests >= 2.5.0, != 2.15, != 2.16
1313
requests-toolbelt >= 0.8.0
1414
pkginfo >= 1.0

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020

2121
install_requires = [
22-
"tqdm >= 4.11",
22+
"tqdm >= 4.14",
2323
"pkginfo >= 1.0",
2424
"requests >= 2.5.0, != 2.15, != 2.16",
2525
"requests-toolbelt >= 0.8.0",

twine/repository.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,13 @@
3434

3535

3636
class ProgressBar(tqdm):
37-
3837
def update_to(self, n):
3938
"""Update the bar in the way compatible with requests-toolbelt.
4039
4140
This is identical to tqdm.update, except ``n`` will be the current
4241
value - not the delta as tqdm expects.
4342
"""
44-
self.update(n - self.n)
43+
self.update(n - self.n) # will also do self.n = n
4544

4645

4746
class Repository(object):
@@ -136,8 +135,9 @@ def _upload(self, package):
136135
(package.basefilename, fp, "application/octet-stream"),
137136
))
138137
encoder = MultipartEncoder(data_to_send)
139-
with ProgressBar(total=encoder.len, unit='bytes',
140-
unit_scale=True, leave=False) as bar:
138+
with ProgressBar(total=encoder.len,
139+
unit='B', unit_scale=True, unit_divisor=1024,
140+
miniters=1) as bar:
141141
monitor = MultipartEncoderMonitor(
142142
encoder, lambda monitor: bar.update_to(monitor.bytes_read)
143143
)

0 commit comments

Comments
 (0)