use argparse
This commit is contained in:
parent
f5dfeb2ce0
commit
0e4a3a145b
1 changed files with 8 additions and 11 deletions
|
@ -5,7 +5,7 @@ from __future__ import division
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
from optparse import OptionParser
|
from argparse import ArgumentParser
|
||||||
from ox.image import drawText, wrapText
|
from ox.image import drawText, wrapText
|
||||||
|
|
||||||
root_dir = os.path.normpath(os.path.abspath(os.path.dirname(__file__)))
|
root_dir = os.path.normpath(os.path.abspath(os.path.dirname(__file__)))
|
||||||
|
@ -75,18 +75,15 @@ def render(infile, outfile):
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
parser = OptionParser()
|
parser = ArgumentParser()
|
||||||
parser.add_option(
|
parser.add_argument(
|
||||||
'-i', '--infile', dest='infile', help='txt file to be read'
|
'-i', '--infile', dest='infile', help='txt file to be read', required=True
|
||||||
)
|
)
|
||||||
parser.add_option(
|
parser.add_argument(
|
||||||
'-o', '--outfile', dest='outfile', help='jpg file to be written'
|
'-o', '--outfile', dest='outfile', help='jpg file to be written', required=True
|
||||||
)
|
)
|
||||||
(options, args) = parser.parse_args()
|
options = parser.parse_args()
|
||||||
if None in (options.infile, options.outfile):
|
render(options.infile, options.outfile)
|
||||||
parser.print_help()
|
|
||||||
else:
|
|
||||||
render(options.infile, options.outfile)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
Loading…
Reference in a new issue