aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/wikiget/__init__.py2
-rw-r--r--src/wikiget/dl.py17
-rw-r--r--src/wikiget/validations.py2
-rw-r--r--src/wikiget/wikiget.py47
4 files changed, 30 insertions, 38 deletions
diff --git a/src/wikiget/__init__.py b/src/wikiget/__init__.py
index 5b917cf..3946868 100644
--- a/src/wikiget/__init__.py
+++ b/src/wikiget/__init__.py
@@ -1,5 +1,5 @@
# wikiget - CLI tool for downloading files from Wikimedia sites
-# Copyright (C) 2018-2021 Cody Logan and contributors
+# Copyright (C) 2018-2023 Cody Logan and contributors
# SPDX-License-Identifier: GPL-3.0-or-later
#
# Wikiget is free software: you can redistribute it and/or modify
diff --git a/src/wikiget/dl.py b/src/wikiget/dl.py
index 791db61..d32736f 100644
--- a/src/wikiget/dl.py
+++ b/src/wikiget/dl.py
@@ -1,5 +1,5 @@
# wikiget - CLI tool for downloading files from Wikimedia sites
-# Copyright (C) 2018-2021 Cody Logan and contributors
+# Copyright (C) 2018-2023 Cody Logan and contributors
# SPDX-License-Identifier: GPL-3.0-or-later
#
# Wikiget is free software: you can redistribute it and/or modify
@@ -65,8 +65,8 @@ def download(dl, args):
if args.username and args.password:
site.login(args.username, args.password)
except ConnectionError as e:
- # usually this means there is no such site, or there's no network
- # connection, though it could be a certificate problem
+ # usually this means there is no such site, or there's no network connection,
+ # though it could be a certificate problem
logging.error("Couldn't connect to specified site.")
logging.debug("Full error message:")
logging.debug(e)
@@ -80,8 +80,8 @@ def download(dl, args):
logging.debug(e)
sys.exit(1)
except (InvalidResponse, LoginError) as e:
- # InvalidResponse: site exists, but we couldn't communicate with the
- # API endpoint for some reason other than an HTTP error.
+ # InvalidResponse: site exists, but we couldn't communicate with the API
+ # endpoint for some reason other than an HTTP error.
# LoginError: missing or invalid credentials
logging.error(e)
sys.exit(1)
@@ -90,8 +90,8 @@ def download(dl, args):
try:
file = site.images[filename]
except APIError as e:
- # an API error at this point likely means access is denied,
- # which could happen with a private wiki
+ # an API error at this point likely means access is denied, which could happen
+ # with a private wiki
logging.error(
"Access denied. Try providing credentials with "
"--username and --password."
@@ -102,8 +102,7 @@ def download(dl, args):
sys.exit(1)
if file.imageinfo != {}:
- # file exists either locally or at a common repository,
- # like Wikimedia Commons
+ # file exists either locally or at a common repository, like Wikimedia Commons
file_url = file.imageinfo["url"]
file_size = file.imageinfo["size"]
file_sha1 = file.imageinfo["sha1"]
diff --git a/src/wikiget/validations.py b/src/wikiget/validations.py
index dc70df4..8ebd996 100644
--- a/src/wikiget/validations.py
+++ b/src/wikiget/validations.py
@@ -1,5 +1,5 @@
# wikiget - CLI tool for downloading files from Wikimedia sites
-# Copyright (C) 2018, 2019, 2020 Cody Logan
+# Copyright (C) 2018-2020 Cody Logan
# SPDX-License-Identifier: GPL-3.0-or-later
#
# Wikiget is free software: you can redistribute it and/or modify
diff --git a/src/wikiget/wikiget.py b/src/wikiget/wikiget.py
index bc6de38..934107e 100644
--- a/src/wikiget/wikiget.py
+++ b/src/wikiget/wikiget.py
@@ -1,5 +1,5 @@
# wikiget - CLI tool for downloading files from Wikimedia sites
-# Copyright (C) 2018-2021 Cody Logan and contributors
+# Copyright (C) 2018-2023 Cody Logan and contributors
# SPDX-License-Identifier: GPL-3.0-or-later
#
# Wikiget is free software: you can redistribute it and/or modify
@@ -25,32 +25,27 @@ from wikiget.dl import download
def main():
"""
- Main entry point for console script. Automatically compiled by setuptools
- when installed with `pip install` or `python setup.py install`.
+ Main entry point for console script. Automatically compiled by setuptools when
+ installed with `pip install` or `python setup.py install`.
"""
parser = argparse.ArgumentParser(
description="""
- A tool for downloading files from
- MediaWiki sites using the file name or
+ A tool for downloading files from MediaWiki sites using the file name or
description page URL
""",
epilog="""
- Copyright (C) 2018-2023 Cody Logan
- and contributors.
- License GPLv3+: GNU GPL version 3 or later
- <http://www.gnu.org/licenses/gpl.html>.
- This is free software; you are free to
- change and redistribute it under certain
- conditions. There is NO WARRANTY, to the
- extent permitted by law.
+ Copyright (C) 2018-2023 Cody Logan and contributors. License GPLv3+: GNU GPL
+ version 3 or later <http://www.gnu.org/licenses/gpl.html>. This is free
+ software; you are free to change and redistribute it under certain conditions.
+ There is NO WARRANTY, to the extent permitted by law.
""",
)
parser.add_argument(
"FILE",
help="""
- name of the file to download with the File:
- prefix, or the URL of its file description page
+ name of the file to download with the File: prefix, or the URL of its file
+ description page
""",
)
parser.add_argument(
@@ -96,9 +91,8 @@ def main():
output_options.add_argument(
"-a",
"--batch",
- help="treat FILE as a textfile containing "
- "multiple files to download, one URL or "
- "filename per line",
+ help="treat FILE as a textfile containing multiple files to download, one URL "
+ "or filename per line",
action="store_true",
)
parser.add_argument(
@@ -117,7 +111,7 @@ def main():
loglevel = logging.ERROR
# configure logging:
- # console log level is set via -v, -vv, and -q options
+ # console log level is set via -v, -vv, and -q options;
# file log level is always info (TODO: add debug option)
if args.logfile:
# log to console and file
@@ -128,8 +122,8 @@ def main():
)
console = logging.StreamHandler()
- # TODO: even when loglevel is set to logging.DEBUG,
- # debug messages aren't printing to console
+ # TODO: even when loglevel is set to logging.DEBUG, debug messages aren't
+ # printing to console
console.setLevel(loglevel)
console.setFormatter(logging.Formatter("[%(levelname)s] %(message)s"))
logging.getLogger("").addHandler(console)
@@ -137,8 +131,8 @@ def main():
# log only to console
logging.basicConfig(level=loglevel, format="[%(levelname)s] %(message)s")
- # log events are appended to the file if it already exists,
- # so note the start of a new download session
+ # log events are appended to the file if it already exists, so note the start of a
+ # new download session
logging.info(f"Starting download session using wikiget {wikiget.wikiget_version}")
# logging.info(f"Log level is set to {loglevel}")
@@ -159,16 +153,15 @@ def main():
sys.exit(1)
else:
with fd:
- # store file contents in memory in case something
- # happens to the file while we're downloading
+ # store file contents in memory in case something happens to the file
+ # while we're downloading
for _, line in enumerate(fd):
dl_list.append(line)
# TODO: validate file contents before download process starts
for line_num, url in enumerate(dl_list, start=1):
s_url = url.strip()
- # keep track of batch file line numbers for
- # debugging/logging purposes
+ # keep track of batch file line numbers for debugging/logging purposes
logging.info(f"Downloading '{s_url}' at line {line_num}:")
download(s_url, args)
else: