From c730b72532ee8f0fd972f651a5bbea49aba64754 Mon Sep 17 00:00:00 2001 From: humziq Date: Wed, 20 Oct 2021 17:52:08 -0500 Subject: [PATCH] Pad progress string with spaces in print_progress() Useful to clear previous data if line's length decreases --- edl/Library/utils.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/edl/Library/utils.py b/edl/Library/utils.py index 4292618..3ebeddd 100755 --- a/edl/Library/utils.py +++ b/edl/Library/utils.py @@ -580,7 +580,10 @@ def print_progress(iteration, total, prefix='', suffix='', decimals=1, bar_lengt filled_length = int(round(bar_length * iteration / float(total))) bar = '█' * filled_length + '-' * (bar_length - filled_length) - sys.stdout.write('\r%s |%s| %s%s %s' % (prefix, bar, percents, '%', suffix)) + progstring = '\r%s |%s| %s%s %s' % (prefix, bar, percents, '%', suffix) + cols, _ = shutil.get_terminal_size() + progstring += " " * (cols - len(progstring) - 1) + sys.stdout.write(progstring) if iteration == total: sys.stdout.write('\n')