aboutsummaryrefslogtreecommitdiff
path: root/backend/tolData/enwiki/downloadImgs.py
diff options
context:
space:
mode:
authorTerry Truong <terry06890@gmail.com>2022-08-20 13:16:21 +1000
committerTerry Truong <terry06890@gmail.com>2022-08-20 13:16:21 +1000
commit930c12d33e1093f874a4beb4d6376621e464e8c0 (patch)
tree381722fc3ab9ebda482cb18d29e1091458aa93da /backend/tolData/enwiki/downloadImgs.py
parent8144003565797f0d18645a416b95d4365bba5fdd (diff)
Use argparse in python scripts
Diffstat (limited to 'backend/tolData/enwiki/downloadImgs.py')
-rwxr-xr-xbackend/tolData/enwiki/downloadImgs.py11
1 files changed, 4 insertions, 7 deletions
diff --git a/backend/tolData/enwiki/downloadImgs.py b/backend/tolData/enwiki/downloadImgs.py
index 8fb605f..520677f 100755
--- a/backend/tolData/enwiki/downloadImgs.py
+++ b/backend/tolData/enwiki/downloadImgs.py
@@ -5,19 +5,16 @@ import sqlite3
import urllib.parse, requests
import time, signal
-usageInfo = f"""
-Usage: {sys.argv[0]}
-
+import argparse
+parser = argparse.ArgumentParser(description="""
Downloads images from URLs in an image database, into an output directory,
with names of the form 'pageId1.ext1'.
SIGINT causes the program to finish an ongoing download and exit.
The program can be re-run to continue downloading, and looks
in the output directory do decide what to skip.
-"""
-if len(sys.argv) > 1:
- print(usageInfo, file=sys.stderr)
- sys.exit(1)
+""", formatter_class=argparse.RawDescriptionHelpFormatter)
+parser.parse_args()
imgDb = "imgData.db" # About 130k image names
outDir = "imgs"