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( |