On 21/05/15 02:02, Dylan Baker wrote:
From: Dylan Baker <dylanx.c.ba...@intel.com>
This results in slightly less code, but code that is much more readable.
It has the advantage of putting everything together in one place, all of
the code is self documenting, help messages are auto-generated, choices
are automatically enforced, and the syntax is much less C like, taking
advantage of python features and idioms.
Signed-off-by: Dylan Baker <dylanx.c.ba...@intel.com>
---
src/mapi/glapi/gen/gl_table.py | 70 ++++++++++++++++++++----------------------
1 file changed, 33 insertions(+), 37 deletions(-)
diff --git a/src/mapi/glapi/gen/gl_table.py b/src/mapi/glapi/gen/gl_table.py
index 3245625..30903fd 100644
--- a/src/mapi/glapi/gen/gl_table.py
+++ b/src/mapi/glapi/gen/gl_table.py
@@ -26,8 +26,7 @@
# Authors:
# Ian Romanick <i...@us.ibm.com>
-import sys
-import getopt
+import argparse
import gl_XML
import license
@@ -203,45 +202,42 @@ class PrintRemapTable(gl_XML.gl_print_base):
return
-def show_usage():
- print "Usage: %s [-f input_file_name] [-m mode] [-c ver]" % sys.argv[0]
- print " -m mode Mode can be 'table' or 'remap_table'."
- print " -c ver Version can be 'es1' or 'es2'."
- sys.exit(1)
+def _parser():
+ """Parse arguments and return a namespace."""
+ parser = argparse.ArgumentParser()
+ parser.add_argument('-f', '--filename',
+ type=gl_XML.parse_GL_API,
+ default='gl_API.xml',
This patch is causing problems on one of my Windows build machines.
It looks like argparse will call gl_XML.parse_GL_API() with the default
'gl_API.xml' value, _even_ when one specifies -f argument in the command
line.
I think the problem might be with particular version of argparse
implementations, not the Windows OS. This was with Python 2.7.3 BTW.
I could upgrade python, but using argparse' type arguments like this
seems a bad idea regardless. Not only argparse implementation can't be
trusted, but also gl_XML.parse_GL_API takes multiple arguments, so it's
not a straightforward constructor.
For example, src/mapi/glapi/gen/gl_procs.py has this
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,
[...]
Which looks quite hard to read IMO over simply doing
api = gl_XML.parse_GL_API(args.file_name, glX_XML.glx_item_factory()
I'm going to undo these hunks, and I'm going to take the liberty of
pushing this as I got no good build over the extended weekend, so we've
been totally blind to regressions on this platform over this period.
Jose
_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev