Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env 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 """Builds the complete main.html file from the basic components. | 6 """Builds the complete main.html file from the basic components. |
| 7 """ | 7 """ |
| 8 | 8 |
| 9 from HTMLParser import HTMLParser | 9 from HTMLParser import HTMLParser |
| 10 import argparse | 10 import argparse |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 136 parser.add_argument('output_file') | 136 parser.add_argument('output_file') |
| 137 parser.add_argument('input_template') | 137 parser.add_argument('input_template') |
| 138 return parser.parse_args(sys.argv[1:]) | 138 return parser.parse_args(sys.argv[1:]) |
| 139 | 139 |
| 140 | 140 |
| 141 def main(): | 141 def main(): |
| 142 args = parseArgs() | 142 args = parseArgs() |
| 143 | 143 |
| 144 out_file = args.output_file | 144 out_file = args.output_file |
| 145 js_files = set(args.js) - set(args.exclude_js) | 145 js_files = set(args.js) - set(args.exclude_js) |
| 146 instrumented_js_files = set(args.instrument_js) - set(args.exclude_js) | |
|
jam
2015/08/07 15:54:00
the comment on line 126 above says this should be
| |
| 146 | 147 |
| 147 # Create the output directory if it does not exist. | 148 # Create the output directory if it does not exist. |
| 148 out_directory = os.path.dirname(out_file) | 149 out_directory = os.path.dirname(out_file) |
| 149 if out_directory is not '' and not os.path.exists(out_directory): | 150 if out_directory is not '' and not os.path.exists(out_directory): |
| 150 os.makedirs(out_directory) | 151 os.makedirs(out_directory) |
| 151 | 152 |
| 152 # Generate the main HTML file from the templates. | 153 # Generate the main HTML file from the templates. |
| 153 with open(out_file, 'w') as output: | 154 with open(out_file, 'w') as output: |
| 154 gen = GenerateWebappHtml(args.templates, js_files, args.instrument_js, | 155 gen = GenerateWebappHtml(args.templates, js_files, instrumented_js_files, |
| 155 args.template_dir) | 156 args.template_dir) |
| 156 gen.processTemplate(output, args.input_template, 0) | 157 gen.processTemplate(output, args.input_template, 0) |
| 157 | 158 |
| 158 # Verify that all the expected templates were found. | 159 # Verify that all the expected templates were found. |
| 159 if not gen.verifyTemplateList(): | 160 if not gen.verifyTemplateList(): |
| 160 error('Extra templates specified') | 161 error('Extra templates specified') |
| 161 | 162 |
| 162 # Verify that the generated HTML file is valid. | 163 # Verify that the generated HTML file is valid. |
| 163 with open(out_file, 'r') as input_html: | 164 with open(out_file, 'r') as input_html: |
| 164 parser = HtmlChecker() | 165 parser = HtmlChecker() |
| 165 parser.feed(input_html.read()) | 166 parser.feed(input_html.read()) |
| 166 | 167 |
| 167 | 168 |
| 168 if __name__ == '__main__': | 169 if __name__ == '__main__': |
| 169 sys.exit(main()) | 170 sys.exit(main()) |
| OLD | NEW |