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

Unified Diff: mojo/public/tools/bindings/pylib/mojom/generate/template_expander.py

Issue 2250183003: Make the fuchsia mojo/public repo the source of truth. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 4 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: mojo/public/tools/bindings/pylib/mojom/generate/template_expander.py
diff --git a/mojo/public/tools/bindings/pylib/mojom/generate/template_expander.py b/mojo/public/tools/bindings/pylib/mojom/generate/template_expander.py
deleted file mode 100644
index dcbb1c808ef014f1a725e3237cf0f0cfdbd10c5d..0000000000000000000000000000000000000000
--- a/mojo/public/tools/bindings/pylib/mojom/generate/template_expander.py
+++ /dev/null
@@ -1,52 +0,0 @@
-# Copyright 2013 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-# Based on:
-# http://src.chromium.org/viewvc/blink/trunk/Source/build/scripts/template_expander.py
-
-import imp
-import inspect
-import os.path
-import sys
-
-# Disable lint check for finding modules:
-# pylint: disable=F0401
-
-try:
- imp.find_module("jinja2")
-except ImportError:
- # Assume this file is in tools/pylib/bindings/mojom/generate.
- sys.path.append(os.path.join(os.path.dirname(os.path.realpath(__file__)),
- os.pardir, os.pardir, os.pardir, os.pardir,
- os.pardir, "third_party"))
-import jinja2
-
-
-def ApplyTemplate(mojo_generator, base_dir, path_to_template, params,
- filters=None, **kwargs):
- template_directory, template_name = os.path.split(path_to_template)
- path_to_templates = os.path.join(base_dir, template_directory)
- loader = jinja2.FileSystemLoader([path_to_templates])
- final_kwargs = dict(mojo_generator.GetJinjaParameters())
- final_kwargs.update(kwargs)
- jinja_env = jinja2.Environment(loader=loader, keep_trailing_newline=True,
- **final_kwargs)
- jinja_env.globals.update(mojo_generator.GetGlobals())
- if filters:
- jinja_env.filters.update(filters)
- template = jinja_env.get_template(template_name)
- return template.render(params)
-
-
-def UseJinja(path_to_template, **kwargs):
- # Get the directory of our caller's file.
- base_dir = os.path.dirname(inspect.getfile(sys._getframe(1)))
- def RealDecorator(generator):
- def GeneratorInternal(*args, **kwargs2):
- parameters = generator(*args, **kwargs2)
- return ApplyTemplate(args[0], base_dir, path_to_template, parameters,
- **kwargs)
- GeneratorInternal.func_name = generator.func_name
- return GeneratorInternal
- return RealDecorator

Powered by Google App Engine
This is Rietveld 408576698