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

Unified Diff: native_client_sdk/src/doc/doxygen/rst_index.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/doc/doxygen/rst_index.py
diff --git a/native_client_sdk/src/doc/doxygen/rst_index.py b/native_client_sdk/src/doc/doxygen/rst_index.py
index 9706f97c4dbad8d5e59241ae6bde67f8a2c1d61b..001c75949b9395dee0e70a561f65395ac9a2278f 100755
--- a/native_client_sdk/src/doc/doxygen/rst_index.py
+++ b/native_client_sdk/src/doc/doxygen/rst_index.py
@@ -5,7 +5,7 @@
import cStringIO
import fnmatch
-import optparse
+import argparse
binji 2014/11/13 23:57:02 sort
Sam Clegg 2014/11/30 17:55:12 Done.
import os
import re
import sys
@@ -227,24 +227,18 @@ def GenerateCppIndex(root_dir, channel, version, out_filename):
def main(argv):
- usage = 'Usage: %prog [options] <--root|--c|--cpp> directory'
- parser = optparse.OptionParser(usage=usage)
- parser.add_option('--channel', help='pepper channel (stable, beta, dev)')
- parser.add_option('--version', help='pepper version (e.g. 32, 33, 34, etc.)')
- parser.add_option('--root', help='Generate root API index',
- action='store_true', default=False)
- parser.add_option('--c', help='Generate C API index', action='store_true',
- default=False)
- parser.add_option('--cpp', help='Generate C++ API index', action='store_true',
- default=False)
- parser.add_option('-o', '--output', help='output file.')
- options, files = parser.parse_args(argv)
-
- if len(files) != 1:
- parser.error('Expected one directory')
-
- if not options.output:
- parser.error('Need output file')
+ parser = argparse.ArgumentParser(description=__doc__)
binji 2014/11/13 23:57:02 no doc?
Sam Clegg 2014/11/30 17:55:12 Done.
+ parser.add_argument('--channel', help='pepper channel (stable, beta, dev)')
+ parser.add_argument('--version', help='pepper version (e.g. 32, 33, etc.)')
+ parser.add_argument('--root', help='Generate root API index',
+ action='store_true', default=False)
+ parser.add_argument('--c', help='Generate C API index', action='store_true',
+ default=False)
+ parser.add_argument('--cpp', help='Generate C++ API index',
+ action='store_true', default=False)
+ parser.add_argument('directory', help='input directory')
+ parser.add_argument('output_file', help='output file')
+ options = parser.parse_args(argv)
if options.channel not in VALID_CHANNELS:
parser.error('Expected channel to be one of %s' % ', '.join(VALID_CHANNELS))
@@ -252,14 +246,16 @@ def main(argv):
if sum((options.c, options.cpp, options.root)) != 1:
parser.error('Exactly one of --c/--cpp/--root flags is required.')
- root_dir = files[0]
if options.c:
- GenerateCIndex(root_dir, options.channel, options.version, options.output)
+ GenerateCIndex(options.directory, options.channel, options.version,
+ options.output_file)
elif options.cpp:
- GenerateCppIndex(root_dir, options.channel, options.version, options.output)
+ GenerateCppIndex(options.directory, options.channel, options.version,
+ options.output_file)
elif options.root:
- GenerateRootIndex(options.channel, options.version, options.output)
+ GenerateRootIndex(options.channel, options.version,
+ options.output_file)
else:
assert(False)
return 0

Powered by Google App Engine
This is Rietveld 408576698