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 | |
| parent | 905a8712fe68b728ee573beb6b3c2486ef3fc569 (diff) | |
| download | wikiget-78bab6f49006fbcf0ca3a0ba63572c2169d12507.tar.gz wikiget-78bab6f49006fbcf0ca3a0ba63572c2169d12507.zip | |
Make chunk size a constant
Diffstat (limited to 'wikiget')
| -rw-r--r-- | wikiget/__init__.py | 1 | ||||
| -rw-r--r-- | wikiget/dl.py | 9 |
2 files changed, 6 insertions, 4 deletions
diff --git a/wikiget/__init__.py b/wikiget/__init__.py index dccd7a5..8437ebf 100644 --- a/wikiget/__init__.py +++ b/wikiget/__init__.py @@ -21,6 +21,7 @@ from .version import __version__ as wikiget_version # set some global constants BLOCKSIZE = 65536 +CHUNKSIZE = 1024 DEFAULT_SITE = 'commons.wikimedia.org' DEFAULT_PATH = '/w/' USER_AGENT = ('wikiget/{} (https://github.com/clpo13/wikiget) ' 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)) |
