add progress.Tqdm(bytes)

This commit is contained in:
Casper da Costa-Luis
2019-08-10 14:15:16 +01:00
parent 62cbeed8b3
commit 6aee6b6b16
2 changed files with 8 additions and 2 deletions
+7
View File
@@ -15,10 +15,17 @@ class Tqdm(tqdm):
disable=logging.getLogger(
__name__).getEffectiveLevel() >= logging.CRITICAL,
ascii=None, # TODO: True?
bytes=False,
**kwargs):
"""
bytes : adds unit='B', unit_scale=True, unit_divisor=1024, miniters=1
kwargs : anything accepted by `tqdm.tqdm()`
"""
if bytes:
#kwargs = deepcopy(kwargs)
for k, v in dict(unit='B', unit_scale=True, unit_divisor=1024,
miniters=1):
kwargs.setdefault(k, v)
super(Tqdm, self).__init__(
iterable=iterable,
disable=disable,
+1 -2
View File
@@ -35,8 +35,7 @@ class RemoteHTTP(RemoteBASE):
#if total:
# leave = total > self.CHUNK_SIZE * 100
with Tqdm(total=total, leave=leave,
unit='B', unit_scale=True, unit_divisor=1024, miniters=1,
with Tqdm(total=total, leave=leave, bytes=True,
disable=no_progress_bar) as pbar:
with open(to_file, "wb") as fd:
for chunk in request.iter_content(chunk_size=self.CHUNK_SIZE):