aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDylan Baker <baker.dylan.c@gmail.com>2013-03-21 09:20:40 -0700
committerKenneth Graunke <kenneth@whitecape.org>2013-04-21 14:42:27 -0700
commitd168a2eef36c7b2f1f6de41929acae1f9c1c638a (patch)
treee6dbc12a9831c0c0d06c19c5bc25bdfa5185a75f
parent03a234d5f0ff4245a842eae7017d49b254293c0f (diff)
downloadpiglit-d168a2eef36c7b2f1f6de41929acae1f9c1c638a.tar.gz
piglit-summary-junit.py: Convert optparse to argparse
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. V2: Dropped some unrelated code per Ken Graunke Signed-off-by: Dylan Baker <baker.dylan.c@gmail.com> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
-rwxr-xr-xpiglit-summary-junit.py32
1 files changed, 16 insertions, 16 deletions
diff --git a/piglit-summary-junit.py b/piglit-summary-junit.py
index 65208889..7ed5de3d 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,21 +109,21 @@ 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:])
-
- if len(args) != 1:
- optparser.error('need to specify one test result')
- usage()
-
- writer = Writer(options.output)
- writer.write(args[0])
+ 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()
+
+
+ writer = Writer(args.output)
+ writer.write(args.testResults)
if __name__ == "__main__":