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

Unified Diff: native_client_sdk/src/tools/fix_manifest.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
« no previous file with comments | « native_client_sdk/src/tools/fix_deps.py ('k') | native_client_sdk/src/tools/genhttpfs.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: native_client_sdk/src/tools/fix_manifest.py
diff --git a/native_client_sdk/src/tools/fix_manifest.py b/native_client_sdk/src/tools/fix_manifest.py
index 4d4d194af1a77ce0f85610d8f7e7b29d126416fc..28729b98776fe226ddbb283c7555beb5ead52632 100755
--- a/native_client_sdk/src/tools/fix_manifest.py
+++ b/native_client_sdk/src/tools/fix_manifest.py
@@ -34,9 +34,9 @@ Becomes
...
"""
+import argparse
import collections
import json
-import optparse
import os
import sys
@@ -57,28 +57,23 @@ def Trace(msg):
Trace.verbose = False
-def main(argv):
- parser = optparse.OptionParser(
- usage='Usage: %prog [options] manifest.json', description=__doc__)
- parser.add_option('-p', '--prefix',
- help='Prefix to set for all sub_package_paths in the '
- 'manifest. If none is specified, the prefix will be '
- 'removed; i.e. the start of the path will be '
- '"_platform_specific/..."')
- parser.add_option('-v', '--verbose',
- help='Verbose output', action='store_true')
+def main(args):
+ parser = argparse.ArgumentParser(description=__doc__)
+ parser.add_argument('-p', '--prefix',
+ help='Prefix to set for all sub_package_paths in the '
+ 'manifest. If none is specified, the prefix will be '
+ 'removed; i.e. the start of the path will be '
+ '"_platform_specific/..."')
+ parser.add_argument('-v', '--verbose',
+ help='Verbose output', action='store_true')
+ parser.add_argument('manifest_json')
- options, args = parser.parse_args(argv)
+ options = parser.parse_args(args)
if options.verbose:
Trace.verbose = True
- if not args:
- parser.error('Expected manifest file.')
-
- manifest = args[0]
-
- Trace('Reading %s' % manifest)
- with open(manifest) as f:
+ Trace('Reading %s' % options.manifest_json)
+ with open(options.manifest_json) as f:
# Keep the dictionary order. This is only supported on Python 2.7+
if sys.version_info >= (2, 7, 0):
data = json.load(f, object_pairs_hook=collections.OrderedDict)
@@ -86,7 +81,7 @@ def main(argv):
data = json.load(f)
if 'platforms' not in data:
- raise Error('%s does not have "platforms" key.' % manifest)
+ raise Error('%s does not have "platforms" key.' % options.manifest_json)
platforms = data['platforms']
if type(platforms) is not list:
@@ -114,7 +109,7 @@ def main(argv):
Trace(' %s: "%s" -> "%s"' % (nacl_arch, sub_package_path, new_path))
- with open(manifest, 'w') as f:
+ with open(options.manifest_json, 'w') as f:
json.dump(data, f, indent=2)
return 0
« no previous file with comments | « native_client_sdk/src/tools/fix_deps.py ('k') | native_client_sdk/src/tools/genhttpfs.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698