Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 """Build the NOTICE file distributed with the NaCl SDK from a set of given | 6 """Build the NOTICE file distributed with the NaCl SDK from a set of given |
| 7 license files.""" | 7 license files.""" |
| 8 | 8 |
| 9 import optparse | 9 import argparse |
| 10 import os | 10 import os |
| 11 import sys | 11 import sys |
| 12 | 12 |
| 13 | 13 |
| 14 def Trace(msg): | 14 def Trace(msg): |
| 15 if Trace.verbose: | 15 if Trace.verbose: |
| 16 print msg | 16 print msg |
| 17 | 17 |
| 18 Trace.verbose = False | 18 Trace.verbose = False |
| 19 | 19 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 61 license_dict = CreateLicenseDict(found_files) | 61 license_dict = CreateLicenseDict(found_files) |
| 62 with open(output_filename, 'w') as output_file: | 62 with open(output_filename, 'w') as output_file: |
| 63 for i, license_filenames in enumerate(sorted(license_dict.iterkeys())): | 63 for i, license_filenames in enumerate(sorted(license_dict.iterkeys())): |
| 64 license_text = license_dict[license_filenames] | 64 license_text = license_dict[license_filenames] |
| 65 if i: | 65 if i: |
| 66 output_file.write('\n\n\n') | 66 output_file.write('\n\n\n') |
| 67 WriteLicense(output_file, root, license_text, license_filenames) | 67 WriteLicense(output_file, root, license_text, license_filenames) |
| 68 | 68 |
| 69 | 69 |
| 70 def main(args): | 70 def main(args): |
| 71 parser = optparse.OptionParser() | 71 parser = argparse.ArgumentParser(description=__doc__) |
| 72 parser.add_option('-v', '--verbose', help='Verbose output.', | 72 parser.add_argument('-v', '--verbose', help='Verbose output.', |
| 73 action='store_true') | 73 action='store_true') |
| 74 parser.add_option('-o', '--output', help='Output file') | 74 parser.add_argument('-o', '--output', help='Output file') |
| 75 parser.add_option('--root', help='Root for all paths') | 75 parser.add_argument('--root', help='Root for all paths') |
| 76 parser.add_argument('files') | |
|
binji
2014/11/13 23:57:01
nargs='*'
Sam Clegg
2014/11/30 17:55:11
Done.
| |
| 76 | 77 |
| 77 options, args = parser.parse_args(args) | 78 options = parser.parse_args(args) |
| 78 Trace.verbose = options.verbose | 79 Trace.verbose = options.verbose |
| 79 | 80 |
| 80 if not options.output: | 81 if not options.output: |
| 81 parser.error('No output file given. See -o.') | 82 parser.error('No output file given. See -o.') |
| 82 if not options.root: | 83 if not options.root: |
| 83 parser.error('No root directory given. See --root.') | 84 parser.error('No root directory given. See --root.') |
| 84 | 85 |
| 85 Generate(options.output, options.root, args) | 86 Generate(options.output, options.root, options.files) |
| 86 Trace('Done.') | 87 Trace('Done.') |
| 87 | 88 |
| 88 return 0 | 89 return 0 |
| 89 | 90 |
| 90 | 91 |
| 91 if __name__ == '__main__': | 92 if __name__ == '__main__': |
| 92 sys.exit(main(sys.argv[1:])) | 93 sys.exit(main(sys.argv[1:])) |
| OLD | NEW |