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

Unified Diff: native_client_sdk/src/build_tools/parse_dsc.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 5 years, 11 months 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/build_tools/parse_dsc.py
diff --git a/native_client_sdk/src/build_tools/parse_dsc.py b/native_client_sdk/src/build_tools/parse_dsc.py
index 409eb402082eef495991807ac4487a8a7b19a71b..5047469b1e8bdf2931dc56b1b83b4c79d5b60114 100755
--- a/native_client_sdk/src/build_tools/parse_dsc.py
+++ b/native_client_sdk/src/build_tools/parse_dsc.py
@@ -3,9 +3,9 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
+import argparse
import collections
import fnmatch
-import optparse
import os
import sys
@@ -244,24 +244,18 @@ def PrintProjectTree(tree):
print '\t' + val['NAME']
-def main(argv):
- parser = optparse.OptionParser(usage='%prog [options] <dir>')
- parser.add_option('-e', '--experimental',
+def main(args):
+ parser = argparse.ArgumentParser(description=__doc__)
+ parser.add_argument('-e', '--experimental',
help='build experimental examples and libraries', action='store_true')
- parser.add_option('-t', '--toolchain',
+ parser.add_argument('-t', '--toolchain',
help='Build using toolchain. Can be passed more than once.',
action='append')
+ parser.add_argument('project_root', default='.')
- options, args = parser.parse_args(argv)
+ options = parser.parse_args(args)
filters = {}
- load_from_dir = '.'
- if len(args) > 1:
- parser.error('Expected 0 or 1 args, got %d.' % len(args))
-
- if args:
- load_from_dir = args[0]
-
if options.toolchain:
filters['TOOLS'] = options.toolchain
@@ -269,7 +263,7 @@ def main(argv):
filters['EXPERIMENTAL'] = False
try:
- tree = LoadProjectTree(load_from_dir, include=filters)
+ tree = LoadProjectTree(options.project_root, include=filters)
except ValidationError as e:
sys.stderr.write(str(e) + '\n')
return 1
« no previous file with comments | « native_client_sdk/src/build_tools/nacl-mono-builder.py ('k') | native_client_sdk/src/build_tools/test_projects.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698