| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 2 # Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file |
| 3 # for details. All rights reserved. Use of this source code is governed by a | 3 # for details. All rights reserved. Use of this source code is governed by a |
| 4 # BSD-style license that can be found in the LICENSE file. | 4 # BSD-style license that can be found in the LICENSE file. |
| 5 | 5 |
| 6 from optparse import OptionParser | 6 from optparse import OptionParser |
| 7 | 7 |
| 8 def writePatch(output_file_name, input_file_names): | 8 def writePatch(output_file_name, input_file_names): |
| 9 dart_file_names = filter(lambda name: name.endswith('.dart'), | 9 dart_file_names = filter(lambda name: name.endswith('.dart'), |
| 10 input_file_names) | 10 input_file_names) |
| 11 with open(output_file_name, 'w') as output_file: | 11 with open(output_file_name, 'w') as output_file: |
| 12 is_first = True |
| 12 for dart_file_name in dart_file_names: | 13 for dart_file_name in dart_file_names: |
| 13 with open(dart_file_name, 'r') as dart_file: | 14 with open(dart_file_name, 'r') as dart_file: |
| 14 output_file.write(dart_file.read()) | 15 if is_first: |
| 16 output_file.write(dart_file.read()) |
| 17 is_first = False |
| 18 else: |
| 19 for line in dart_file.readlines(): |
| 20 if not line.startswith("import "): |
| 21 output_file.write(line) |
| 15 | 22 |
| 16 | 23 |
| 17 def main(): | 24 def main(): |
| 18 parser = OptionParser() | 25 parser = OptionParser() |
| 19 parser.add_option('--output', action='store', type='string', | 26 parser.add_option('--output', action='store', type='string', |
| 20 help='output file path') | 27 help='output file path') |
| 21 (options, args) = parser.parse_args() | 28 (options, args) = parser.parse_args() |
| 22 if not options.output: | 29 if not options.output: |
| 23 parser.error('missing --output option\n') | 30 parser.error('missing --output option\n') |
| 24 if len(args) == 0: | 31 if len(args) == 0: |
| 25 parser.error('no input files given\n') | 32 parser.error('no input files given\n') |
| 26 writePatch(options.output, args) | 33 writePatch(options.output, args) |
| 27 | 34 |
| 28 | 35 |
| 29 if __name__ == '__main__': | 36 if __name__ == '__main__': |
| 30 main() | 37 main() |
| OLD | NEW |