fix unknown total progress

- depends on https://github.com/tqdm/tqdm/pull/800
This commit is contained in:
Casper da Costa-Luis
2019-08-26 01:27:03 +01:00
parent c9342754ed
commit 06f920d138
+11 -4
View File
@@ -32,6 +32,11 @@ class Tqdm(tqdm):
"""
maximum-compatibility tqdm-based progressbars
"""
BAR_FMT_DEFAULT = (
"{percentage:3.0f}%|{bar:10}|{desc} {bar:-10b}{n}/{total}"
" [{elapsed}<{remaining}, {rate_fmt:>11}{postfix}]"
)
BAR_FMT_NOTOTAL = "{desc} {bar:b}{n} [{elapsed}<??:??, {rate_fmt:>11}{postfix}]"
def __init__(
self,
@@ -40,10 +45,7 @@ class Tqdm(tqdm):
bytes=False, # pylint: disable=W0622
desc_truncate=None,
leave=None,
bar_format=(
"{percentage:3.0f}%|{bar:10}|{desc} {bar:-10b}{n}/{total}"
" [{elapsed}<{remaining}, {rate_fmt:>11}{postfix}]"
),
bar_format=None,
**kwargs
):
"""
@@ -66,6 +68,11 @@ class Tqdm(tqdm):
logging.getLogger(__name__).getEffectiveLevel()
>= logging.CRITICAL
)
if bar_format is None:
if kwargs.get('total', getattr(iterable, '__len__', None)) is None:
bar_format = self.BAR_FMT_NOTOTAL
else:
bar_format = self.BAR_FMT_DEFAULT
super(Tqdm, self).__init__(
iterable=iterable,
disable=disable,