mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-04 20:38:06 +02:00
glapi: gl_apitemp.py: Convert to argparse instead of getopt
Signed-off-by: Dylan Baker <dylanx.c.baker@intel.com> Acked-by: Matt Turner <mattst88@gmail.com>
This commit is contained in:
parent
6c4dcef6dc
commit
24ec03bd05
1 changed files with 19 additions and 20 deletions
|
|
@ -25,9 +25,10 @@
|
|||
# Authors:
|
||||
# Ian Romanick <idr@us.ibm.com>
|
||||
|
||||
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)
|
||||
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()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
file_name = "gl_API.xml"
|
||||
args = _parser()
|
||||
|
||||
try:
|
||||
(args, trail) = getopt.getopt(sys.argv[1:], "f:c")
|
||||
except Exception,e:
|
||||
show_usage()
|
||||
api = gl_XML.parse_GL_API(args.filename, glX_XML.glx_item_factory())
|
||||
|
||||
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 = PrintGlOffsets(es)
|
||||
printer = PrintGlOffsets(args.es)
|
||||
printer.Print(api)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue