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 75% |
copy from Source/core/core.gyp/scripts/supplemental_idl_files.py |
copy to Source/core/scripts/template_expander.py |
index eaf0270ac9f6a46637b6196233f09793d855e4b8..e09826c5a6f5a0a502c3ff3b8ccd730a6dcfa322 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,18 @@ |
# (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 |
import sys |
-partial_interface_regex = re.compile(r'partial\s+interface\s+(\w+).+\]', re.M | re.S) |
+_curdir = os.path.dirname(os.path.realpath(__file__)) |
+# jinja2 is in chromium's third_party directory |
+sys.path.append(os.path.join(_curdir, *([os.pardir] * 4))) |
+ |
-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): |
abarth-chromium
2013/05/10 16:18:40
applytemplate -> apply_template
pathtotemplate ->
|
+ import jinja2 |
+ dirname, basename = os.path.split(pathtotemplate) |
+ pathtotemplates = os.path.join(_curdir, "templates") |
+ env = jinja2.Environment(loader=jinja2.FileSystemLoader([dirname, pathtotemplates])) |
+ template = env.get_template(basename) |
+ return template.render(params) |