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

Unified Diff: tools/grit/grit/format/policy_templates/template_formatter.py

Issue 3116027: Add Mac output for policy template generator (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: final nits Created 10 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
« no previous file with comments | « chrome/chrome.gyp ('k') | tools/grit/grit/format/policy_templates/writers/adm_writer.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/grit/grit/format/policy_templates/template_formatter.py
diff --git a/tools/grit/grit/format/policy_templates/template_formatter.py b/tools/grit/grit/format/policy_templates/template_formatter.py
index 2e5633a15a368ff61854939a934c0ed22088ba07..ddbb0ccefff78cd06462e784d1785beb2b3d8bc4 100644
--- a/tools/grit/grit/format/policy_templates/template_formatter.py
+++ b/tools/grit/grit/format/policy_templates/template_formatter.py
@@ -59,7 +59,7 @@ class TemplateFormatter(interface.ItemFormatter):
self._lang = lang
self._GetFlags(item)
- self._policy_groups = None
+ self._policy_data = None
self._messages = {}
self._ParseGritNodes(item)
return self._GetOutput()
@@ -72,8 +72,9 @@ class TemplateFormatter(interface.ItemFormatter):
The text of the policy template based on the parameters passed
to __init__() and Format().
'''
- policy_generator = \
- PolicyTemplateGenerator(self._messages, self._policy_groups)
+ policy_generator = PolicyTemplateGenerator(
+ self._messages,
+ self._policy_data['policy_groups'])
writer = self._writer_module.GetWriter(self._info, self._messages)
str = policy_generator.GetTemplateText(writer)
return str
@@ -107,8 +108,14 @@ class TemplateFormatter(interface.ItemFormatter):
message: A <message> node in the grit tree.
'''
msg_name = message.GetTextualIds()[0]
+ # Get translation of message.
msg_txt = message.Translate(self._lang)
+ # Replace the placeholder of app name.
msg_txt = msg_txt.replace('$1', self._info['app_name'])
+ # Replace other placeholders.
+ for placeholder in self._policy_data['placeholders']:
+ msg_txt = msg_txt.replace(placeholder['key'], placeholder['value'])
+ # Strip spaces and escape newlines.
lines = msg_txt.split('\n')
lines = [line.strip() for line in lines]
msg_txt = "\\n".join(lines)
@@ -126,8 +133,8 @@ class TemplateFormatter(interface.ItemFormatter):
return
if (isinstance(item, structure.StructureNode) and
item.attrs['type'] == 'policy_template_metafile'):
- assert self._policy_groups == None
- self._policy_groups = item.gatherer.GetData()
+ assert self._policy_data == None
+ self._policy_data = item.gatherer.GetData()
elif (isinstance(item, message.MessageNode)):
self._ImportMessage(item)
for child in item.children:
« no previous file with comments | « chrome/chrome.gyp ('k') | tools/grit/grit/format/policy_templates/writers/adm_writer.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698