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

Unified Diff: native_client_sdk/src/tools/genhttpfs.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_manifest.py ('k') | native_client_sdk/src/tools/getos.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: native_client_sdk/src/tools/genhttpfs.py
diff --git a/native_client_sdk/src/tools/genhttpfs.py b/native_client_sdk/src/tools/genhttpfs.py
index 4e9aa92007964edcfe75151c49ada97a3bf07a55..8cd7e50d32b3c44d27ba44d7618a89806e4ce5f8 100755
--- a/native_client_sdk/src/tools/genhttpfs.py
+++ b/native_client_sdk/src/tools/genhttpfs.py
@@ -11,8 +11,8 @@ For each file, the mode bits, size and path relative to the CWD are written
to the output file which is stdout by default.
"""
+import argparse
import glob
-import optparse
import os
import sys
import urllib
@@ -21,19 +21,19 @@ class Error(Exception):
pass
-def main(argv):
- parser = optparse.OptionParser(description=__doc__,
- usage='Usage: %prog [options] <filename>...')
- parser.add_option('-C', '--srcdir',
- help='Change directory.', dest='srcdir', default=None)
- parser.add_option('-o', '--output',
- help='Output file name.', dest='output', default=None)
- parser.add_option('-v', '--verbose',
- help='Verbose output.', dest='verbose',
- action='store_true')
- parser.add_option('-r', '--recursive',
- help='Recursive search.', action='store_true')
- options, args = parser.parse_args(argv)
+def main(args):
+ parser = argparse.ArgumentParser(description=__doc__)
+ parser.add_argument('-C', '--srcdir',
+ help='Change directory.', dest='srcdir', default=None)
+ parser.add_argument('-o', '--output',
+ help='Output file name.', dest='output', default=None)
+ parser.add_argument('-v', '--verbose',
+ help='Verbose output.', dest='verbose',
+ action='store_true')
+ parser.add_argument('-r', '--recursive',
+ help='Recursive search.', action='store_true')
+ parser.add_argument('paths', nargs='+')
+ options = parser.parse_args(args)
if options.output:
outfile = open(options.output, 'w')
@@ -43,12 +43,9 @@ def main(argv):
if options.srcdir:
os.chdir(options.srcdir)
- if not args:
- parser.error("One or more pathnames must be specified. See --help.")
-
# Generate a set of unique file names bases on the input globs
fileset = set()
- for fileglob in args:
+ for fileglob in options.paths:
filelist = glob.glob(fileglob)
if not filelist:
raise Error('Could not find match for "%s".\n' % fileglob)
« no previous file with comments | « native_client_sdk/src/tools/fix_manifest.py ('k') | native_client_sdk/src/tools/getos.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698