From 34029f56f5c95deea9f5fcfbcf5750da9c97b5bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20Mart=C3=ADnez=20Portela?= Date: Fri, 17 Dec 2021 09:58:19 +0100 Subject: [PATCH] Clean progressbar when needed. --- macli.py | 1 + progress_meter.py | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/macli.py b/macli.py index 5c282c5..8719cec 100644 --- a/macli.py +++ b/macli.py @@ -189,6 +189,7 @@ def archive_to_dir(directory, url): with open('index.html', 'wt') as f: f.write(archived_content.prettify()) + progbar.clean() os.chdir(current_path) diff --git a/progress_meter.py b/progress_meter.py index 54cddd8..7aecd3c 100644 --- a/progress_meter.py +++ b/progress_meter.py @@ -28,3 +28,9 @@ class ProgressBar: def next_iter(self, msg=''): self.current_element += 1 self.show(msg) + + def clean(self): + print('\r' # Go to the start of the line + '\x1b[K' # Clear line + '\x1b[0m', # Restart the "style" + end='')