From d972bc113f60a7602c7078914dcc03a84401bbf1 Mon Sep 17 00:00:00 2001 From: Cody Logan Date: Tue, 24 Oct 2023 13:30:40 -0700 Subject: Tweak progress bar appearance --- src/wikiget/dl.py | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/src/wikiget/dl.py b/src/wikiget/dl.py index 64281c8..5213863 100644 --- a/src/wikiget/dl.py +++ b/src/wikiget/dl.py @@ -122,25 +122,22 @@ def download(f: File, args: Namespace) -> int: except OSError as e: adapter.error(f"File could not be written. {e}") errors += 1 - else: - # download the file(s) - if args.verbose >= wikiget.STD_VERBOSE: - leave_bars = True - else: - leave_bars = False - with tqdm( - leave=leave_bars, - total=file_size, - unit="B", - unit_scale=True, - unit_divisor=wikiget.CHUNKSIZE, - ) as progress_bar: - with fd: - res = site.connection.get(file_url, stream=True) - progress_bar.set_postfix(file=dest, refresh=False) - for chunk in res.iter_content(wikiget.CHUNKSIZE): - fd.write(chunk) - progress_bar.update(len(chunk)) + return errors + # download the file(s) + leave_bars = args.verbose >= wikiget.STD_VERBOSE + with tqdm( + desc=dest, + leave=leave_bars, + total=file_size, + unit="B", + unit_scale=True, + unit_divisor=wikiget.CHUNKSIZE, + ) as progress_bar: + with fd: + res = site.connection.get(file_url, stream=True) + for chunk in res.iter_content(wikiget.CHUNKSIZE): + fd.write(chunk) + progress_bar.update(len(chunk)) # verify file integrity and log details dl_sha1 = verify_hash(dest) -- cgit v1.2.3