diff options
| author | Cody Logan <clpo13@gmail.com> | 2020-08-21 14:07:28 -0700 |
|---|---|---|
| committer | Cody Logan <clpo13@gmail.com> | 2020-08-21 14:07:37 -0700 |
| commit | 78bab6f49006fbcf0ca3a0ba63572c2169d12507 (patch) | |
| tree | eb775ef8ab571a7eba6ba5bdbf98634368706098 /wikiget/dl.py | |
| parent | 905a8712fe68b728ee573beb6b3c2486ef3fc569 (diff) | |
| download | wikiget-78bab6f49006fbcf0ca3a0ba63572c2169d12507.tar.gz wikiget-78bab6f49006fbcf0ca3a0ba63572c2169d12507.zip | |
Make chunk size a constant
Diffstat (limited to 'wikiget/dl.py')
| -rw-r--r-- | wikiget/dl.py | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/wikiget/dl.py b/wikiget/dl.py index 6a9b0e2..6cbe8df 100644 --- a/wikiget/dl.py +++ b/wikiget/dl.py @@ -23,7 +23,7 @@ from mwclient import APIError, InvalidResponse, LoginError, Site from requests import ConnectionError, HTTPError from tqdm import tqdm -from . import DEFAULT_SITE, USER_AGENT +from . import CHUNKSIZE, DEFAULT_SITE, USER_AGENT from .validations import valid_file, verify_hash @@ -137,12 +137,13 @@ def download(dl, args): leave_bars = True else: leave_bars = False - with tqdm(leave=leave_bars, total=file_size, unit='B', - unit_scale=True, unit_divisor=1024) as progress_bar: + with tqdm(leave=leave_bars, total=file_size, + unit='B', unit_scale=True, + unit_divisor=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(1024): + for chunk in res.iter_content(CHUNKSIZE): fd.write(chunk) progress_bar.update(len(chunk)) |
