Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(22)

Unified Diff: native_client_sdk/src/tools/ncval.py

Issue 720233003: [NaCl SDK] Convert python scripts from optparse to argparse. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: native_client_sdk/src/tools/ncval.py
diff --git a/native_client_sdk/src/tools/ncval.py b/native_client_sdk/src/tools/ncval.py
index 2066487b3ea734354a43bab770f0c040a78480aa..c6aa1ea3e00607f16d69073070048ef65ff99357 100755
--- a/native_client_sdk/src/tools/ncval.py
+++ b/native_client_sdk/src/tools/ncval.py
@@ -3,10 +3,10 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-"""Wrapper script for running ncval.
+"""Wrapper script for running the Native Client validator (ncval).
"""
-import optparse
+import argparse
import os
import subprocess
import sys
@@ -28,12 +28,12 @@ def Log(msg):
sys.stderr.write(str(msg) + '\n')
Log.verbose = False
-def main(argv):
- usage = 'Usage: %prog [options] <.nexe | .so>'
- epilog = 'Example: ncval.py my_nexe.nexe'
- parser = optparse.OptionParser(usage, description=__doc__, epilog=epilog)
- parser.add_option('-v', '--verbose', action='store_true',
- help='Verbose output')
+def main(args):
+ parser = argparse.ArgumentParser(description=__doc__)
+ parser.add_argument('-v', '--verbose', action='store_true',
+ help='Verbose output')
+ parser.add_argument('args', metavar="EXE", nargs='+',
binji 2014/11/13 23:57:04 exes?
Sam Clegg 2014/11/30 17:55:13 Done.
+ help='Executable to validate')
# To enable bash completion for this command first install optcomplete
# and then add this line to your .bashrc:
@@ -44,11 +44,9 @@ def main(argv):
except ImportError:
pass
- options, args = parser.parse_args(argv)
- if not args:
- parser.error('No executable file specified')
+ options = parser.parse_args(args)
- nexe = args[0]
+ nexe = options.args[0]
if options.verbose:
Log.verbose = True

Powered by Google App Engine
This is Rietveld 408576698