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 4fd28ebc3221eddf46b08cb391260f999f9af200..f29d66bf3218587dcc84141b14d95b48e3b19a16 100644 |
--- a/tools/grit/grit/format/policy_templates/template_formatter.py |
+++ b/tools/grit/grit/format/policy_templates/template_formatter.py |
@@ -75,34 +75,12 @@ class TemplateFormatter(interface.ItemFormatter): |
to __init__() and Format(). |
''' |
policy_generator = policy_template_generator.PolicyTemplateGenerator( |
- self._messages, |
- self._policy_data['policy_definitions']) |
- writer = self._writer_module.GetWriter(self._config, self._messages) |
+ self._config, |
+ self._policy_data) |
+ writer = self._writer_module.GetWriter(self._config) |
str = policy_generator.GetTemplateText(writer) |
return str |
- def _ImportMessage(self, message): |
- '''Takes a grit message node and adds its translated content to |
- self._messages. |
- |
- Args: |
- 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._config['app_name']) |
- msg_txt = msg_txt.replace('$3', self._config['frame_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) |
- self._messages[msg_name] = msg_txt |
- |
def _ParseGritNodes(self, item): |
'''Collects the necessary information from the grit tree: |
the message strings and the policy definitions. |
@@ -116,8 +94,6 @@ class TemplateFormatter(interface.ItemFormatter): |
if (isinstance(item, structure.StructureNode) and |
item.attrs['type'] == 'policy_template_metafile'): |
assert self._policy_data == None |
- self._policy_data = item.gatherer.GetData() |
- elif (isinstance(item, message.MessageNode)): |
- self._ImportMessage(item) |
+ self._policy_data = eval(item.gatherer.Translate(self._lang)) |
for child in item.children: |
self._ParseGritNodes(child) |