aboutsummaryrefslogtreecommitdiff
path: root/backend/tolData/enwiki/genDescData.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/genDescData.py
parent8144003565797f0d18645a416b95d4365bba5fdd (diff)
Use argparse in python scripts
Diffstat (limited to 'backend/tolData/enwiki/genDescData.py')
-rwxr-xr-xbackend/tolData/enwiki/genDescData.py15
1 files changed, 6 insertions, 9 deletions
diff --git a/backend/tolData/enwiki/genDescData.py b/backend/tolData/enwiki/genDescData.py
index b0ca272..0085d70 100755
--- a/backend/tolData/enwiki/genDescData.py
+++ b/backend/tolData/enwiki/genDescData.py
@@ -5,15 +5,12 @@ import bz2
import html, mwxml, mwparserfromhell
import sqlite3
-usageInfo = f"""
-Usage: {sys.argv[0]}
-
-Reads through the wiki dump, and attempts to
-parse short-descriptions, and add them to a database.
-"""
-if len(sys.argv) > 1:
- print(usageInfo, file=sys.stderr)
- sys.exit(1)
+import argparse
+parser = argparse.ArgumentParser(description="""
+Reads through the wiki dump, and attempts to parse short-descriptions,
+and add them to a database
+""", formatter_class=argparse.RawDescriptionHelpFormatter)
+parser.parse_args()
dumpFile = "enwiki-20220501-pages-articles-multistream.xml.bz2" # Had about 22e6 pages
enwikiDb = "descData.db"