aboutsummaryrefslogtreecommitdiff
path: root/src/wikiget
diff options
context:
space:
mode:
authorCody Logan <cody@lokken.dev>2023-10-24 13:30:40 -0700
committerCody Logan <cody@lokken.dev>2023-10-24 13:30:40 -0700
commitd972bc113f60a7602c7078914dcc03a84401bbf1 (patch)
tree3a8c84f2901baa48c1655ab1a865c67c285da829 /src/wikiget
parent159ab526e6c2efc7a080bb5f2a495c19ad217d93 (diff)
downloadwikiget-d972bc113f60a7602c7078914dcc03a84401bbf1.tar.gz
wikiget-d972bc113f60a7602c7078914dcc03a84401bbf1.zip
Tweak progress bar appearance
Diffstat (limited to 'src/wikiget')
-rw-r--r--src/wikiget/dl.py35
1 files 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)