8000 Replace clint by tqdm for progressbar · pypa/twine@42e55e0 · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Commit 42e55e0

Browse files
committed
Replace clint by tqdm for progressbar
Closes #241 – As clint as some indirect Python 2 dependency and tqdm has not.
1 parent 6fa84f5 commit 42e55e0

File tree

4 files changed

+26
-17
lines changed

4 files changed

+26
-17
lines changed

setup.cfg

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ ignore =
88

99
[metadata]
1010
requires-dist =
11-
clint
11+
tqdm >= 4.11
1212
requests >= 2.5.0
1313
requests-toolbelt >= 0.5.1
1414
pkginfo >= 1.0

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020

2121
install_requires = [
22-
"clint",
22+
"tqdm >= 4.11",
2323
"pkginfo >= 1.0",
2424
"requests >= 2.5.0",
2525
"requests-toolbelt >= 0.5.1",

twine/cli.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import pkg_resources
1919
import setuptools
2020

21-
import clint
21+
import tqdm
2222
import requests
2323
import requests_toolbelt
2424
import pkginfo
@@ -38,7 +38,7 @@ def list_dependencies_and_versions():
3838
('requests', requests.__version__),
3939
('setuptools', setuptools.__version__),
4040
('requests-toolbelt', requests_toolbelt.__version__),
41-
('clint', clint.__version__),
41+
('tqdm', tqdm.__version__),
4242
]
4343

4444

twine/repository.py

+22-13
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# limitations under the License.
1414
from __future__ import absolute_import, unicode_literals, print_function
1515

16-
from clint.textui.progress import Bar as ProgressBar
16+
from tqdm import tqdm as tqdm
1717

1818
import requests
1919
from requests import adapters
@@ -33,6 +33,15 @@
3333
OLD_WAREHOUSE = 'https://upload.pypi.io/'
3434

3535

36+
class ProgressBar(tqdm):
37+
38+
def update_to(self, n):
39+
"""
40+
identical to update, except `n` should be current value and not delta.
41+
"""
42+
self.update(n - self.n)
43+
44+
3645
class Repository(object):
3746
def __init__(self, repository_url, username, password):
3847
self.url = repository_url
@@ -121,18 +130,18 @@ def _upload(self, package):
121130
(package.basefilename, fp, "application/octet-stream"),
122131
))
123132
encoder = MultipartEncoder(data_to_send)
124-
bar = ProgressBar(expected_size=encoder.len, filled_char='=')
125-
monitor = MultipartEncoderMonitor(
126-< 8000 /span>
encoder, lambda monitor: bar.show(monitor.bytes_read)
127-
)
128-
129-
resp = self.session.post(
130-
self.url,
131-
data=monitor,
132-
allow_redirects=False,
133-
headers={'Content-Type': monitor.content_type},
134-
)
135-
bar.done()
133+
with ProgressBar(total=encoder.len, unit='bytes',
134+
unit_scale=True, leave=False) as bar:
135+
monitor = MultipartEncoderMonitor(
136+
encoder, lambda monitor: bar.update_to(monitor.bytes_read)
137+
)
138+
139+
resp = self.session.post(
140+
self.url,
141+
data=monitor,
142+
allow_redirects=False,
143+
headers={'Content-Type': monitor.content_type},
144+
)
136145

137146
return resp
138147

0 commit comments

Comments
 (0)
0