From 5d373de1dac4d9ac2dfe2ea9e8fcc4f8b4b06069 Mon Sep 17 00:00:00 2001 From: Casper da Costa-Luis Date: Mon, 26 Aug 2019 01:24:38 +0100 Subject: [PATCH] support custom bar_format with unknown total --- tqdm/_tqdm.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/tqdm/_tqdm.py b/tqdm/_tqdm.py index 1e27fa69..0c562651 100755 --- a/tqdm/_tqdm.py +++ b/tqdm/_tqdm.py @@ -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 '') + \