Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1382)

Unified Diff: Source/core/scripts/template_expander.py

Issue 15095002: Use jinja2 for make_runtime_features and make_internal_runtime_flags (Closed) Base URL: https://chromium.googlesource.com/chromium/blink@master
Patch Set: Updated for Eric's suggestions Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 74%
copy from Source/core/core.gyp/scripts/supplemental_idl_files.py
copy to Source/core/scripts/template_expander.py
index eaf0270ac9f6a46637b6196233f09793d855e4b8..60a272c10f650965557b8508b6044ffa9b1dbe7d 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)
+_current_dir = os.path.dirname(os.path.realpath(__file__))
+# jinja2 is in chromium's third_party directory
+sys.path.append(os.path.join(_current_dir, *([os.pardir] * 4)))
+import jinja2
+
-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 apply_template(path_to_template, params):
+ dirname, basename = os.path.split(path_to_template)
+ path_to_templates = os.path.join(_current_dir, "templates")
+ jinja_env = jinja2.Environment(loader=jinja2.FileSystemLoader([dirname, path_to_templates]))
+ template = jinja_env.get_template(basename)
+ return template.render(params)
« no previous file with comments | « Source/core/scripts/make_runtime_features.py ('k') | Source/core/scripts/templates/InternalRuntimeFlags.h.tmpl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698