aboutsummaryrefslogtreecommitdiff
path: root/src/wikiget/dl.py
diff options
context:
space:
mode:
authorCody Logan <cody@lokken.dev>2023-11-15 10:36:18 -0800
committerGitHub <noreply@github.com>2023-11-15 10:36:18 -0800
commitbf3a7db6cf83fa7d224d84c47b40cfe32603019c (patch)
treeffeb394c3da9e4a2dcbc6a92caa956d5c83441eb /src/wikiget/dl.py
parent55a5311ee4da639a65bd60622315f3fff6936c9a (diff)
downloadwikiget-bf3a7db6cf83fa7d224d84c47b40cfe32603019c.tar.gz
wikiget-bf3a7db6cf83fa7d224d84c47b40cfe32603019c.zip
Convert File.dest from a string to a Path (#14)
Diffstat (limited to 'src/wikiget/dl.py')
-rw-r--r--src/wikiget/dl.py7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/wikiget/dl.py b/src/wikiget/dl.py
index 9b2777f..60405d0 100644
--- a/src/wikiget/dl.py
+++ b/src/wikiget/dl.py
@@ -19,7 +19,6 @@ import logging
import sys
from argparse import Namespace
from concurrent.futures import ThreadPoolExecutor
-from pathlib import Path
from mwclient import APIError, InvalidResponse, LoginError
from requests import ConnectionError, HTTPError
@@ -54,7 +53,7 @@ def prep_download(dl: str, args: Namespace) -> File:
file = get_dest(dl, args)
# check if the destination file already exists; don't overwrite unless the user says
- if Path(file.dest).is_file() and not args.force:
+ if file.dest.is_file() and not args.force:
msg = f"[{file.dest}] File already exists; skipping download (use -f to force)"
raise FileExistsError(msg)
@@ -203,13 +202,13 @@ def download(f: File, args: Namespace) -> int:
try:
with tqdm(
- desc=dest,
+ desc=str(dest),
leave=args.verbose >= wikiget.STD_VERBOSE,
total=file_size,
unit="B",
unit_scale=True,
unit_divisor=wikiget.CHUNKSIZE,
- ) as progress_bar, Path(dest).open("wb") as fd:
+ ) as progress_bar, dest.open("wb") as fd:
# download the file using the existing Site session
res = site.connection.get(file_url, stream=True)
for chunk in res.iter_content(wikiget.CHUNKSIZE):