diff options
author | Dylan Baker <[email protected]> | 2014-11-24 14:14:12 -0800 |
---|---|---|
committer | Matt Turner <[email protected]> | 2015-05-22 11:31:27 -0700 |
commit | e51530ba1665af7120be852653bbff930fa1ca33 (patch) | |
tree | 5f4938626170f63553e12c93c744dbef8d134754 /src/mapi/glapi/gen | |
parent | 28ecdd6be7e6f58eabfc9aa0461fb8db7dd8133d (diff) |
glapi: gl_procs.py: Use argparse rather than 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_procs.py | 42 |
1 files changed, 19 insertions, 23 deletions
diff --git a/src/mapi/glapi/gen/gl_procs.py b/src/mapi/glapi/gen/gl_procs.py index d5ffb9286ef..cf6d2de8a4b 100644 --- a/src/mapi/glapi/gen/gl_procs.py +++ b/src/mapi/glapi/gen/gl_procs.py @@ -25,8 +25,7 @@ # Authors: # Ian Romanick <[email protected]> -import sys -import getopt +import argparse import license import gl_XML @@ -164,31 +163,28 @@ typedef struct { 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) +def _parser(): + """Parse arguments and return a namepsace.""" + api_type = lambda x: gl_XML.parse_GL_API(x, glX_XML.glx_item_factory()) + + parser = argparse.ArgumentParser() + parser.add_argument('-f', '--filename', + type=api_type, + default='gl_API.xml', + metavar="input_file_name", + dest='api', + help="Path to an XML description of OpenGL API.") + parser.add_argument('-c', '--es-version', + dest='es', + action="store_true", + help="filter functions for es") + return parser.parse_args() def main(): """Main function.""" - file_name = "gl_API.xml" - - try: - args, _ = getopt.getopt(sys.argv[1:], "f:c") - except Exception: - show_usage() - - es = False - for arg, val in args: - if arg == "-f": - file_name = val - elif arg == "-c": - es = True - - api = gl_XML.parse_GL_API(file_name, glX_XML.glx_item_factory()) - printer = PrintGlProcs(es) - printer.Print(api) + args = _parser() + PrintGlProcs(args.es).Print(args.api) if __name__ == '__main__': |