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

Unified Diff: grit/gather/chrome_html.py

Issue 16539002: GRIT: Enable variable expansion in filenames during HTML inlining. (Closed) Base URL: https://chromium.googlesource.com/external/grit-i18n.git@master
Patch Set: Created 7 years, 6 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: grit/gather/chrome_html.py
diff --git a/grit/gather/chrome_html.py b/grit/gather/chrome_html.py
index d5a2b07cd0e61bc44819bf23ac95c7abc1692601..a1c1f79aa6a42dad4ff0af713b0a626e193ab440 100644
--- a/grit/gather/chrome_html.py
+++ b/grit/gather/chrome_html.py
@@ -238,6 +238,7 @@ class ChromeHtml(interface.GathererBase):
# 1x resources are implicitly already in the source and do not need to be
# added.
self.scale_factors_ = []
+ self.filename_expansion_function = None
def SetAttributes(self, attrs):
self.allow_external_script_ = ('allowexternalscript' in attrs and
@@ -267,7 +268,8 @@ class ChromeHtml(interface.GathererBase):
self.grd_node.ToRealPath(self.GetInputPath()),
allow_external_script=self.allow_external_script_,
rewrite_function=lambda fp, t, d: ProcessImageSets(
- fp, t, self.scale_factors_, d))
+ fp, t, self.scale_factors_, d),
+ filename_expansion_function=self.filename_expansion_function)
return []
def Translate(self, lang, pseudo_if_not_available=True,
@@ -275,10 +277,15 @@ class ChromeHtml(interface.GathererBase):
"""Returns this document translated."""
return self.inlined_text_
+ def SetFilenameExpansionFunction(self, fn):
+ self.filename_expansion_function = fn
+
def Parse(self):
"""Parses and inlines the represented file."""
filename = self.GetInputPath()
+ if self.filename_expansion_function:
+ filename = self.filename_expansion_function(filename)
# Hack: some unit tests supply an absolute path and no root node.
if not os.path.isabs(filename):
filename = self.grd_node.ToRealPath(filename)
@@ -288,7 +295,8 @@ class ChromeHtml(interface.GathererBase):
self.grd_node,
allow_external_script = self.allow_external_script_,
rewrite_function=lambda fp, t, d: ProcessImageSets(
- fp, t, self.scale_factors_, d))
+ fp, t, self.scale_factors_, d),
+ filename_expansion_function=self.filename_expansion_function)
else:
distribution = html_inline.GetDistribution()
self.inlined_text_ = ProcessImageSets(

Powered by Google App Engine
This is Rietveld 408576698