summaryrefslogtreecommitdiffstats
path: root/src/mapi
diff options
context:
space:
mode:
authorDylan Baker <[email protected]>2015-02-13 16:41:03 -0800
committerMatt Turner <[email protected]>2015-05-22 11:31:28 -0700
commitdddac8cac3ab883b6beeb4af9ca27bb2f3b4ebec (patch)
tree850b16b507b50070c98707edba06af2a08cf446e /src/mapi
parent952bd305c6862113c60d3b62402fc5a32dbb65ca (diff)
glapi: glX_server_table.py: use argparse instead of getopt
Signed-off-by: Dylan Baker <[email protected]> Acked-by: Matt Turner <[email protected]>
Diffstat (limited to 'src/mapi')
-rw-r--r--src/mapi/glapi/gen/glX_server_table.py38
1 files changed, 15 insertions, 23 deletions
diff --git a/src/mapi/glapi/gen/glX_server_table.py b/src/mapi/glapi/gen/glX_server_table.py
index 47aa11116be..2d21f4e4ee1 100644
--- a/src/mapi/glapi/gen/glX_server_table.py
+++ b/src/mapi/glapi/gen/glX_server_table.py
@@ -25,8 +25,9 @@
# Authors:
# Ian Romanick <[email protected]>
+import argparse
+
import gl_XML, glX_XML, glX_proto_common, license
-import sys, getopt
def log2(value):
@@ -383,28 +384,19 @@ class PrintGlxDispatchTables(glX_proto_common.glx_print_proto):
return
-if __name__ == '__main__':
- file_name = "gl_API.xml"
-
- try:
- (args, trail) = getopt.getopt(sys.argv[1:], "f:m")
- except Exception,e:
- show_usage()
-
- mode = "table_c"
- for (arg,val) in args:
- if arg == "-f":
- file_name = val
- elif arg == "-m":
- mode = val
+def _parser():
+ """Parse arguments and return namespace."""
+ parser = argparse.ArgumentParser()
+ parser.add_argument('-f',
+ dest='filename',
+ default='gl_API.xml',
+ help='An XML file describing an API.')
+ return parser.parse_args()
- if mode == "table_c":
- printer = PrintGlxDispatchTables()
- else:
- show_usage()
-
-
- api = gl_XML.parse_GL_API( file_name, glX_XML.glx_item_factory() )
+if __name__ == '__main__':
+ args = _parser()
+ printer = PrintGlxDispatchTables()
+ api = gl_XML.parse_GL_API(args.filename, glX_XML.glx_item_factory())
- printer.Print( api )
+ printer.Print(api)