diff options
author | Dylan Baker <[email protected]> | 2015-02-10 10:55:45 -0800 |
---|---|---|
committer | Matt Turner <[email protected]> | 2015-05-22 11:31:27 -0700 |
commit | 24ec03bd05153bf0c8b1063d4e6a68b073e57840 (patch) | |
tree | 61be5680b78c33975702dad75aeeb209ae59ab2b /src/mapi/glapi/gen | |
parent | 6c4dcef6dc704156115b8d3ad19c3020663c7ffc (diff) |
glapi: gl_apitemp.py: Convert to argparse instead of getopt
Signed-off-by: Dylan Baker <[email protected]>
Acked-by: Matt Turner <[email protected]>
Diffstat (limited to 'src/mapi/glapi/gen')
-rw-r--r-- | src/mapi/glapi/gen/gl_apitemp.py | 39 |
1 files changed, 19 insertions, 20 deletions
diff --git a/src/mapi/glapi/gen/gl_apitemp.py b/src/mapi/glapi/gen/gl_apitemp.py index 4157032c5f0..7647428b331 100644 --- a/src/mapi/glapi/gen/gl_apitemp.py +++ b/src/mapi/glapi/gen/gl_apitemp.py @@ -25,9 +25,10 @@ # Authors: # Ian Romanick <[email protected]> +import argparse + import gl_XML, glX_XML import license -import sys, getopt class PrintGlOffsets(gl_XML.gl_print_base): def __init__(self, es=False): @@ -301,27 +302,25 @@ _glapi_proc UNUSED_TABLE_NAME[] = {""" return -def show_usage(): - print "Usage: %s [-f input_file_name] [-c]" % sys.argv[0] - print "-c Enable compatibility with OpenGL ES." - sys.exit(1) - -if __name__ == '__main__': - file_name = "gl_API.xml" +def _parser(): + """Parser arguments and return a namespace.""" + parser = argparse.ArgumentParser() + parser.add_argument('-f', + metavar='<input file name>', + dest='filename', + default="gl_API.xml", + help="An XML file describing the API.") + parser.add_argument('-c', + action='store_true', + dest='es', + help="Enable OpenGL ES compatibility") + return parser.parse_args() - try: - (args, trail) = getopt.getopt(sys.argv[1:], "f:c") - except Exception,e: - show_usage() - es = False - for (arg,val) in args: - if arg == "-f": - file_name = val - elif arg == "-c": - es = True +if __name__ == '__main__': + args = _parser() - api = gl_XML.parse_GL_API(file_name, glX_XML.glx_item_factory()) + api = gl_XML.parse_GL_API(args.filename, glX_XML.glx_item_factory()) - printer = PrintGlOffsets(es) + printer = PrintGlOffsets(args.es) printer.Print(api) |