Optparse has been deprecated in favor of argparse upstream (PEP 389 http://www.python.org/dev/peps/pep-0389/), and since we are using argparse already in the other modules, it makes sense to replace optparse and use only one parsing method in all piglit.
Signed-off-by: Dylan Baker <[email protected]> --- piglit-summary-junit.py | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/piglit-summary-junit.py b/piglit-summary-junit.py index 6520888..5b29c7e 100755 --- a/piglit-summary-junit.py +++ b/piglit-summary-junit.py @@ -24,7 +24,7 @@ # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -import optparse +import argparse import os import sys @@ -109,25 +109,22 @@ class Writer: def main(): - optparser = optparse.OptionParser( - usage="\n\t%prog [options] test.results", - version="%%prog") - optparser.add_option( - '-o', '--output', metavar='FILE', - type="string", dest="output", default='piglit.xml', - help="output filename") - (options, args) = optparser.parse_args(sys.argv[1:]) + parser = argparse.ArgumentParser() + parser.add_argument("-o", "--output", + metavar = "<Output File>", + action = "store", + dest = "output", + default = "piglit.xml", + help = "Output filename") + parser.add_argument("testResults", + metavar = "<Input Files>", + help = "JSON results file to be converted") + args = parser.parse_args() - if len(args) != 1: - optparser.error('need to specify one test result') - usage() - writer = Writer(options.output) - writer.write(args[0]) + writer = Writer(args.output) + writer.write(args.testResults) if __name__ == "__main__": main() - - -# vim:set sw=4 ts=4 noet: -- 1.8.1.4 _______________________________________________ Piglit mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/piglit
