Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 #!/usr/bin/env python | |
| 2 # Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | |
| 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. | |
| 5 # | |
| 6 # Usage: generate_sources_file.py <output-file> <pattern> <directory, ...> | |
|
ahe
2013/04/11 11:40:31
This should be a documentation string.
| |
| 7 # | |
| 8 # This will create <output-file> containing a sorted list of all files in the | |
| 9 # given <directory ...> that match pattern. | |
| 10 | |
| 11 import sys | |
| 12 import os | |
| 13 import list_files | |
| 14 | |
| 15 def main(): | |
| 16 if len(sys.argv) < 4: | |
| 17 raise Exception("Usage generate_sources_file.py <output> <pattern> " | |
| 18 "<directory ...>") | |
| 19 output_file = sys.argv[1] | |
| 20 pattern_str = sys.argv[2] | |
| 21 directories = sys.argv[3:] | |
| 22 files = list_files.list_files(pattern_str, directories) | |
| 23 sources_file_content = "\n".join(sorted(files)) | |
| 24 | |
| 25 with open(output_file, 'w') as fd: | |
| 26 fd.write(sources_file_content) | |
| 27 | |
| 28 if __name__=='__main__': | |
| 29 sys.exit(main()) | |
| OLD | NEW |