OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 # Copyright 2014 The Chromium Authors. All rights reserved. | 2 # Copyright 2014 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 from __future__ import print_function | 6 from __future__ import print_function |
7 | 7 |
8 import argparse | 8 import argparse |
9 import os | 9 import os |
10 import re | 10 import re |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 builders_path = fs.join(BASE_DIR, master_subpath, 'builders.pyl') | 58 builders_path = fs.join(BASE_DIR, master_subpath, 'builders.pyl') |
59 | 59 |
60 if not fs.exists(builders_path): | 60 if not fs.exists(builders_path): |
61 print("%s not found" % master_dirname, file=sys.stderr) | 61 print("%s not found" % master_dirname, file=sys.stderr) |
62 return 1 | 62 return 1 |
63 | 63 |
64 values = chromium_utils.ParseBuildersFileContents( | 64 values = chromium_utils.ParseBuildersFileContents( |
65 builders_path, | 65 builders_path, |
66 fs.read_text_file(builders_path)) | 66 fs.read_text_file(builders_path)) |
67 | 67 |
68 template_dir = fs.join(TEMPLATE_DIR, values['master_type']) | 68 for filename in fs.listfiles(TEMPLATE_DIR): |
69 for filename in fs.listfiles(template_dir): | 69 template = fs.read_text_file(fs.join(TEMPLATE_DIR, filename)) |
70 template = fs.read_text_file(fs.join(template_dir, filename)) | |
71 contents = _expand(template, values, | 70 contents = _expand(template, values, |
72 '%s/%s' % (TEMPLATE_SUBPATH, filename), | 71 '%s/%s' % (TEMPLATE_SUBPATH, filename), |
73 master_subpath) | 72 master_subpath) |
74 fs.write_text_file(fs.join(BASE_DIR, master_subpath, filename), contents) | 73 fs.write_text_file(fs.join(BASE_DIR, master_subpath, filename), contents) |
75 print("Wrote %s." % filename) | 74 print("Wrote %s." % filename) |
76 | 75 |
77 return 0 | 76 return 0 |
78 | 77 |
79 | 78 |
80 def run_help(args, fs): | 79 def run_help(args, fs): |
(...skipping 18 matching lines...) Expand all Loading... |
99 replacement = ('# This file was generated from\n' | 98 replacement = ('# This file was generated from\n' |
100 '# %s\n' | 99 '# %s\n' |
101 '# by "scripts/tools/buildbot-tool gen %s".\n' | 100 '# by "scripts/tools/buildbot-tool gen %s".\n' |
102 '# DO NOT EDIT BY HAND!\n' % | 101 '# DO NOT EDIT BY HAND!\n' % |
103 (source, master_subpath)) | 102 (source, master_subpath)) |
104 return re.sub(pattern, replacement, contents) | 103 return re.sub(pattern, replacement, contents) |
105 | 104 |
106 | 105 |
107 if __name__ == '__main__': # pragma: no cover | 106 if __name__ == '__main__': # pragma: no cover |
108 sys.exit(main(sys.argv[1:], filesystem.Filesystem())) | 107 sys.exit(main(sys.argv[1:], filesystem.Filesystem())) |
OLD | NEW |