Commit 2107a77e authored by Christopher Lam's avatar Christopher Lam Committed by Commit Bot

[style_var_gen] Add override points for google3 integration.

This CL adds easy file path override points for changes that need to be
made to bring the Style Variable Generator into google3.

Bug: 1018654
Change-Id: I4b8fd9de2baeaf7972c9319a05551df32c26b50f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2198702Reviewed-by: default avatarGiovanni Ortuño Urquidi <ortuno@chromium.org>
Commit-Queue: calamity <calamity@chromium.org>
Cr-Commit-Position: refs/heads/master@{#770008}
parent bdc325ce
......@@ -7,6 +7,7 @@ import sys
import collections
import re
import textwrap
import path_overrides
from color import Color
_FILE_PATH = os.path.dirname(os.path.realpath(__file__))
......@@ -89,13 +90,14 @@ class BaseGenerator:
raise ValueError('\n%s:\n %s' % (path, err))
def ApplyTemplate(self, style_generator, path_to_template, params):
current_dir = os.path.dirname(os.path.realpath(__file__))
loader_root_dir = path_overrides.GetFileSystemLoaderRootDirectory()
jinja_env = jinja2.Environment(
loader=jinja2.FileSystemLoader(current_dir),
loader=jinja2.FileSystemLoader(loader_root_dir),
keep_trailing_newline=True)
jinja_env.globals.update(style_generator.GetGlobals())
jinja_env.filters.update(style_generator.GetFilters())
template = jinja_env.get_template(path_to_template)
template = jinja_env.get_template(
path_overrides.GetPathToTemplate(path_to_template))
return template.render(params)
def Validate(self):
......
# Copyright 2020 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.
import os
# Returns the FileSystemLoader root directory. Overridden in google3.
def GetFileSystemLoaderRootDirectory():
return os.path.dirname(os.path.realpath(__file__))
# Returns the path to the template relative to FileSystemLoader root.
# Overridden in google3.
def GetPathToTemplate(path_to_template):
return path_to_template
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment