| OLD | NEW |
| 1 # Copyright 2016 The Chromium Authors. All rights reserved. | 1 # Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import os.path | 5 import os.path |
| 6 import sys | 6 import sys |
| 7 import optparse | 7 import optparse |
| 8 try: | 8 try: |
| 9 import json | 9 import json |
| 10 except ImportError: | 10 except ImportError: |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 # In Blink, jinja2 is in chromium's third_party directory. | 24 # In Blink, jinja2 is in chromium's third_party directory. |
| 25 # Insert at 1 so at front to override system libraries, and | 25 # Insert at 1 so at front to override system libraries, and |
| 26 # after path[0] == invoking script dir | 26 # after path[0] == invoking script dir |
| 27 third_party_dir = os.path.normpath(os.path.join( | 27 third_party_dir = os.path.normpath(os.path.join( |
| 28 module_path, os.pardir, os.pardir, os.pardir, os.pardir)) | 28 module_path, os.pardir, os.pardir, os.pardir, os.pardir)) |
| 29 if os.path.isdir(third_party_dir): | 29 if os.path.isdir(third_party_dir): |
| 30 sys.path.insert(1, third_party_dir) | 30 sys.path.insert(1, third_party_dir) |
| 31 | 31 |
| 32 # In Node, it is in deps folder | 32 # In Node, it is in deps folder |
| 33 deps_dir = os.path.normpath(os.path.join( | 33 deps_dir = os.path.normpath(os.path.join( |
| 34 module_path, os.pardir, os.pardir, os.pardir)) | 34 module_path, os.pardir, os.pardir, "deps")) |
| 35 if os.path.isdir(deps_dir): | 35 if os.path.isdir(deps_dir): |
| 36 sys.path.insert(1, os.path.join(deps_dir, "jinja2")) | 36 sys.path.insert(1, os.path.join(deps_dir, "jinja2")) |
| 37 sys.path.insert(1, os.path.join(deps_dir, "markupsafe")) | 37 sys.path.insert(1, os.path.join(deps_dir, "markupsafe")) |
| 38 | 38 |
| 39 import jinja2 | 39 import jinja2 |
| 40 | 40 |
| 41 cmdline_parser = optparse.OptionParser() | 41 cmdline_parser = optparse.OptionParser() |
| 42 cmdline_parser.add_option("--protocol") | 42 cmdline_parser.add_option("--protocol") |
| 43 cmdline_parser.add_option("--include") | 43 cmdline_parser.add_option("--include") |
| 44 cmdline_parser.add_option("--string_type") | 44 cmdline_parser.add_option("--string_type") |
| (...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 cpp_file = output_file(cpp_file_name) | 346 cpp_file = output_file(cpp_file_name) |
| 347 h_file.write(h_template.render(template_context)) | 347 h_file.write(h_template.render(template_context)) |
| 348 cpp_file.write(cpp_template.render(template_context)) | 348 cpp_file.write(cpp_template.render(template_context)) |
| 349 h_file.close() | 349 h_file.close() |
| 350 cpp_file.close() | 350 cpp_file.close() |
| 351 | 351 |
| 352 | 352 |
| 353 for domain in json_api["domains"]: | 353 for domain in json_api["domains"]: |
| 354 if domain["domain"] in generate_domains: | 354 if domain["domain"] in generate_domains: |
| 355 generate(domain) | 355 generate(domain) |
| OLD | NEW |