Chromium Code Reviews| Index: Source/core/scripts/template_expander.py |
| diff --git a/Source/core/core.gyp/scripts/supplemental_idl_files.py b/Source/core/scripts/template_expander.py |
| similarity index 63% |
| copy from Source/core/core.gyp/scripts/supplemental_idl_files.py |
| copy to Source/core/scripts/template_expander.py |
| index eaf0270ac9f6a46637b6196233f09793d855e4b8..945f521261ef96e9d297a76787f279682cff37b7 100644 |
| --- a/Source/core/core.gyp/scripts/supplemental_idl_files.py |
| +++ b/Source/core/scripts/template_expander.py |
| @@ -1,5 +1,3 @@ |
| -#!/usr/bin/python |
| -# |
| # Copyright (C) 2013 Google Inc. All rights reserved. |
| # |
| # Redistribution and use in source and binary forms, with or without |
| @@ -28,18 +26,24 @@ |
| # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| -"""This file returns a list of all the IDL files that contain a partial interface.""" |
| - |
| -import re |
| +import os.path |
| import sys |
| -partial_interface_regex = re.compile(r'partial\s+interface\s+(\w+).+\]', re.M | re.S) |
| +def _setup(): |
| + autoinstallerpath = "../../../Tools/Scripts/webkitpy/common/system" |
|
abarth-chromium
2013/05/06 18:27:32
Woah, we shouldn't have a dependency across the wo
|
| + sys.path.insert(0, autoinstallerpath) |
| + from autoinstall import AutoInstaller |
| + installer = AutoInstaller() # This won't re-download if the file already exists |
| + installer.install(url="https://pypi.python.org/packages/source/J/Jinja2/Jinja2-2.6.tar.gz#md5=1c49a8825c993bfdcf55bb36897d28a2", url_subpath="Jinja2-2.6/jinja2") |
|
abarth-chromium
2013/05/06 18:27:32
Can we just check jinja into third_party? We don'
|
| + sys.path.insert(0, os.path.join(autoinstallerpath, "autoinstalled")) |
| -def DoMain(filenames): |
| - partial_files = set() |
| - for filename in filenames: |
| - with open(filename) as f: |
| - match = re.search(partial_interface_regex, f.read()) |
| - if match: |
| - partial_files.add(filename) |
| - return '\n'.join(partial_files) |
| +def applytemplate(pathtotemplate, params): |
| + try: |
| + import jinja2 |
| + except ImportError: |
| + _setup() |
| + import jinja2 |
| + dirname, basename = os.path.split(pathtotemplate) |
| + env = jinja2.Environment(loader=jinja2.FileSystemLoader([dirname, "../scripts/templates"])) |
| + template = env.get_template(basename) |
| + return template.render(params) |