support custom bar_format with unknown total

This commit is contained in:
Casper da Costa-Luis 2019-08-26 01:24:38 +01:00
parent 359864cf35
commit 5d373de1da
No known key found for this signature in database
GPG Key ID: 986B408043AE090D
1 changed files with 11 additions and 1 deletions

View File

@ -479,7 +479,17 @@ class tqdm(Comparable):
elif bar_format:
# user-specified bar_format but no total
return bar_format.format(bar='?', **format_dict)
l_bar += '|'
format_dict.update(l_bar=l_bar, percentage=0)
full_bar = FormatReplace()
nobar = bar_format.format(bar=full_bar, **format_dict)
if not full_bar.format_called:
return nobar
full_bar = Bar(
0,
max(1, ncols - len(RE_ANSI.sub('', nobar))) if ncols else 10,
charset=Bar.BLANK)
return bar_format.format(bar=full_bar, **format_dict)
else:
# no total: no progressbar, ETA, just progress stats
return ((prefix + ": ") if prefix else '') + \