Chromium Code Reviews| Index: native_client_sdk/src/tools/fix_deps.py |
| diff --git a/native_client_sdk/src/tools/fix_deps.py b/native_client_sdk/src/tools/fix_deps.py |
| index 91b4fa7e7997df05fb49067620ba0ad1525b471a..c5aff1a42d14134165129a660b875a1bbde31037 100755 |
| --- a/native_client_sdk/src/tools/fix_deps.py |
| +++ b/native_client_sdk/src/tools/fix_deps.py |
| @@ -13,7 +13,7 @@ See http://mad-scientist.net/make/autodep.html for more details of the problem. |
| """ |
| import os |
| -import optparse |
| +import argparse |
|
binji
2014/11/13 23:57:03
sort
|
| import sys |
| TAG_LINE = '# Updated by fix_deps.py\n' |
| @@ -82,24 +82,21 @@ def FixupDepFile(filename, output_filename=None): |
| def main(argv): |
| - usage = "usage: %prog [options] <dep_file>" |
| - parser = optparse.OptionParser(usage=usage, description=__doc__) |
| - parser.add_option('-o', '--output', help='Output filename (defaults to ' |
| + parser = argparse.ArgumentParser(description=__doc__) |
| + parser.add_argument('-o', '--output', help='Output filename (defaults to ' |
| 'input name with .deps extension') |
| - parser.add_option('-c', '--clean', action='store_true', |
| + parser.add_argument('-c', '--clean', action='store_true', |
| help='Remove input file after writing output') |
| - options, args = parser.parse_args(argv) |
| - if not args: |
| - raise parser.error('No input file specified') |
| - if len(args) > 1: |
| - raise parser.error('Only one argument supported') |
| - input_filename = args[0] |
| + parser.add_argument('dep_file') |
| + options = parser.parse_args(argv) |
| output_filename = options.output |
| if not output_filename: |
| - output_filename = os.path.splitext(input_filename)[0] + '.deps' |
| - FixupDepFile(input_filename, output_filename) |
| - if options.clean and input_filename != output_filename: |
| - os.remove(input_filename) |
| + output_filename = os.path.splitext(options.dep_file)[0] + '.deps' |
| + FixupDepFile(options.dep_file, output_filename) |
| + if options.clean and options.dep_file != output_filename: |
| + os.remove(options.dep_file) |
| + |
| + return 0 |
| if __name__ == '__main__': |