Chromium Code Reviews| Index: tools/generate_sources_file.py |
| diff --git a/tools/generate_sources_file.py b/tools/generate_sources_file.py |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..893e2404afa06a4e71d82bab03ee5faca0f72714 |
| --- /dev/null |
| +++ b/tools/generate_sources_file.py |
| @@ -0,0 +1,29 @@ |
| +#!/usr/bin/env python |
| +# Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| +# for details. All rights reserved. Use of this source code is governed by a |
| +# BSD-style license that can be found in the LICENSE file. |
| +# |
| +# Usage: generate_sources_file.py <output-file> <pattern> <directory, ...> |
|
ahe
2013/04/11 11:40:31
This should be a documentation string.
|
| +# |
| +# This will create <output-file> containing a sorted list of all files in the |
| +# given <directory ...> that match pattern. |
| + |
| +import sys |
| +import os |
| +import list_files |
| + |
| +def main(): |
| + if len(sys.argv) < 4: |
| + raise Exception("Usage generate_sources_file.py <output> <pattern> " |
| + "<directory ...>") |
| + output_file = sys.argv[1] |
| + pattern_str = sys.argv[2] |
| + directories = sys.argv[3:] |
| + files = list_files.list_files(pattern_str, directories) |
| + sources_file_content = "\n".join(sorted(files)) |
| + |
| + with open(output_file, 'w') as fd: |
| + fd.write(sources_file_content) |
| + |
| +if __name__=='__main__': |
| + sys.exit(main()) |