diff options
| author | Cody Logan <cody@lokken.dev> | 2023-10-24 13:31:54 -0700 |
|---|---|---|
| committer | Cody Logan <cody@lokken.dev> | 2023-10-24 13:33:42 -0700 |
| commit | b51477decbb74b95b6b33420e26649f8a8d0e70f (patch) | |
| tree | bff559915267225e658fb424d8350d7496316ce9 | |
| parent | 2ea4fc946474ae0d0f3d0b21184f2e025bad7736 (diff) | |
| download | wikiget-b51477decbb74b95b6b33420e26649f8a8d0e70f.tar.gz wikiget-b51477decbb74b95b6b33420e26649f8a8d0e70f.zip | |
Add dry run option, to test processing without actually downloading anything
| -rw-r--r-- | src/wikiget/dl.py | 6 | ||||
| -rw-r--r-- | src/wikiget/wikiget.py | 6 |
2 files changed, 9 insertions, 3 deletions
diff --git a/src/wikiget/dl.py b/src/wikiget/dl.py index 93e9743..5bc24e9 100644 --- a/src/wikiget/dl.py +++ b/src/wikiget/dl.py @@ -116,6 +116,8 @@ def download(f: File, args: Namespace) -> int: if os.path.isfile(dest) and not args.force: adapter.warning("File already exists, skipping download (use -f to force)") errors += 1 + elif args.dry_run: + adapter.warning("Dry run, so nothing actually downloaded") else: try: fd = open(dest, "wb") @@ -143,9 +145,7 @@ def download(f: File, args: Namespace) -> int: try: dl_sha1 = verify_hash(dest) except OSError as e: - adapter.error( - f"File downloaded but could not be verified. {e}" - ) + adapter.error(f"File downloaded but could not be verified. {e}") errors += 1 return errors diff --git a/src/wikiget/wikiget.py b/src/wikiget/wikiget.py index cf877cf..693decb 100644 --- a/src/wikiget/wikiget.py +++ b/src/wikiget/wikiget.py @@ -113,6 +113,12 @@ def construct_parser() -> argparse.ArgumentParser: help="number of parallel downloads to attempt in batch mode", type=int, ) + parser.add_argument( + "-n", + "--dry-run", + action="store_true", + help="check the download or batch file without actually downloading anything", + ) return parser |
