diff options
| author | Terry Truong <terry06890@gmail.com> | 2022-08-20 13:16:21 +1000 |
|---|---|---|
| committer | Terry Truong <terry06890@gmail.com> | 2022-08-20 13:16:21 +1000 |
| commit | 930c12d33e1093f874a4beb4d6376621e464e8c0 (patch) | |
| tree | 381722fc3ab9ebda482cb18d29e1091458aa93da /backend/tolData/genImgs.py | |
| parent | 8144003565797f0d18645a416b95d4365bba5fdd (diff) | |
Use argparse in python scripts
Diffstat (limited to 'backend/tolData/genImgs.py')
| -rwxr-xr-x | backend/tolData/genImgs.py | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/backend/tolData/genImgs.py b/backend/tolData/genImgs.py index ecca8e0..930990b 100755 --- a/backend/tolData/genImgs.py +++ b/backend/tolData/genImgs.py @@ -4,9 +4,8 @@ import sys, os, subprocess import sqlite3, urllib.parse import signal -usageInfo = f""" -Usage: {sys.argv[0]} - +import argparse +parser = argparse.ArgumentParser(description=""" Reads node IDs and image paths from a file, and possibly from a directory, and generates cropped/resized versions of those images into a directory, with names of the form 'nodeId1.jpg'. Also adds image metadata to the @@ -15,10 +14,8 @@ database. SIGINT can be used to stop, and the program can be re-run to continue processing. It uses already-existing database entries to decide what to skip. -""" -if len(sys.argv) > 1: - print(usageInfo, file=sys.stderr) - sys.exit(1) +""", formatter_class=argparse.RawDescriptionHelpFormatter) +parser.parse_args() imgListFile = "imgList.txt" outDir = "img/" |
