From 291d4ab44eaf5fcd2a4033f705170eb27dfe74e8 Mon Sep 17 00:00:00 2001 From: Cody Logan Date: Thu, 16 Nov 2023 11:09:14 -0800 Subject: Fix bug when downloading non-local files from a wiki Revert to the pre-v0.6.0 method of checking for file existence. A change introduced in v0.6.0 caused the check to fail if the file existed only in a shared repository and not locally on the requested wiki. --- src/wikiget/dl.py | 2 +- tests/test_dl.py | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/wikiget/dl.py b/src/wikiget/dl.py index 60405d0..722bf62 100644 --- a/src/wikiget/dl.py +++ b/src/wikiget/dl.py @@ -184,7 +184,7 @@ def download(f: File, args: Namespace) -> int: # prepend the current filename to all log messages adapter = FileLogAdapter(logger, {"filename": filename}) - if file.exists: + if file.imageinfo: # file exists either locally or at a common repository, like Wikimedia Commons file_url = file.imageinfo["url"] file_size = file.imageinfo["size"] diff --git a/tests/test_dl.py b/tests/test_dl.py index cb893b8..e062116 100644 --- a/tests/test_dl.py +++ b/tests/test_dl.py @@ -307,7 +307,6 @@ class TestDownload: """ file = File(name="Example.jpg") file.image = Mock() - file.image.exists = True file.image.imageinfo = { "url": "https://upload.wikimedia.org/wikipedia/commons/a/a9/Example.jpg", "size": 9022, @@ -475,7 +474,7 @@ class TestDownload: self, mock_file: File, caplog: pytest.LogCaptureFixture ) -> None: """Test that a warning message is logged if no file info was returned.""" - mock_file.image.exists = False + mock_file.image.imageinfo = {} args = parse_args(["File:Example.jpg"]) errors = download(mock_file, args) -- cgit v1.2.3 From a4c1e93b24c487ba2b88dccfbf4e68e69bca9c79 Mon Sep 17 00:00:00 2001 From: Cody Logan Date: Thu, 16 Nov 2023 11:42:02 -0800 Subject: Update documentation --- docs/wikiget.1 | 13 ++++++++++--- docs/wikiget.1.md | 11 ++++++++--- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/docs/wikiget.1 b/docs/wikiget.1 index fa1a33d..0d7bf9b 100644 --- a/docs/wikiget.1 +++ b/docs/wikiget.1 @@ -1,6 +1,6 @@ -.\" Automatically generated by Pandoc 3.1.8 +.\" Automatically generated by Pandoc 3.1.9 .\" -.TH "WIKIGET" "1" "October 5, 2023" "Version 0.5.1" "Wikiget User Manual" +.TH "WIKIGET" "1" "November 16, 2023" "Version 0.8.0" "Wikiget User Manual" .SH NAME wikiget - download files from MediaWiki sites .SH SYNOPSIS @@ -81,6 +81,11 @@ If this flag is set, \f[B]wikiget\f[R] will run in batch download mode Number of parallel downloads to attempt in batch mode. This option has no effect if -\f[B]a\f[R] is not also set. .TP +-\f[B]n\f[R], --\f[B]dry-run\f[R] +Do a dry-run of the download process. +Useful for checking the format of a batch file. +Nothing will actually be downloaded. +.TP -\f[B]v\f[R], --\f[B]verbose\f[R] Print additional information, such as the site used and the full URL of the file. @@ -120,4 +125,6 @@ You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/. .SH AUTHORS -Cody Logan . +Cody Logan \c +.MT cody@lokken.dev +.ME \c. diff --git a/docs/wikiget.1.md b/docs/wikiget.1.md index fd274d5..d537942 100644 --- a/docs/wikiget.1.md +++ b/docs/wikiget.1.md @@ -1,6 +1,6 @@ -% WIKIGET(1) Version 0.5.1 | Wikiget User Manual -% Cody Logan -% October 5, 2023 +% WIKIGET(1) Version 0.8.0 | Wikiget User Manual +% Cody Logan +% November 16, 2023 # NAME @@ -72,6 +72,11 @@ the file name or the URL of its description page. : Number of parallel downloads to attempt in batch mode. This option has no effect if \-**a** is not also set. +\-**n**, \-\-**dry-run** + +: Do a dry-run of the download process. Useful for checking the format of a batch file. Nothing will actually be + downloaded. + \-**v**, \-\-**verbose** : Print additional information, such as the site used and the full URL of the file. Additional invocations will -- cgit v1.2.3 From abf8d1cbf22bb5aa5a1dc8a7380177af05bb4b23 Mon Sep 17 00:00:00 2001 From: Cody Logan Date: Thu, 16 Nov 2023 11:43:29 -0800 Subject: Bump version number for release --- src/wikiget/version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wikiget/version.py b/src/wikiget/version.py index 479f200..804c60f 100644 --- a/src/wikiget/version.py +++ b/src/wikiget/version.py @@ -15,4 +15,4 @@ # You should have received a copy of the GNU General Public License # along with Wikiget. If not, see . -__version__ = "0.8.0.dev0" +__version__ = "0.8.0" -- cgit v1.2.3