diff options
author | markusheintz@chromium.org <markusheintz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-03 09:20:59 +0000 |
---|---|---|
committer | markusheintz@chromium.org <markusheintz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-03 09:20:59 +0000 |
commit | ad26476480ee19815eec5d91ceecb29e4cf7a0cf (patch) | |
tree | 6403efdbb9519a8347d7fafc09c17b14b0c25730 /tools/grit | |
parent | 954a26f4065f784a692f482759733cd8c99babcd (diff) | |
download | chromium_src-ad26476480ee19815eec5d91ceecb29e4cf7a0cf.zip chromium_src-ad26476480ee19815eec5d91ceecb29e4cf7a0cf.tar.gz chromium_src-ad26476480ee19815eec5d91ceecb29e4cf7a0cf.tar.bz2 |
Move newline escaping from TemplateFormater to AdmWriters and PListStringsWriter.
BUG=53953
TEST=adm_writer_unittest.py, plist_strings_writer_unittest.py
Review URL: http://codereview.chromium.org/3214014
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@58468 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools/grit')
3 files changed, 10 insertions, 6 deletions
diff --git a/tools/grit/grit/format/policy_templates/template_formatter.py b/tools/grit/grit/format/policy_templates/template_formatter.py index ddbb0cce..fa479a5 100644 --- a/tools/grit/grit/format/policy_templates/template_formatter.py +++ b/tools/grit/grit/format/policy_templates/template_formatter.py @@ -118,7 +118,7 @@ class TemplateFormatter(interface.ItemFormatter): # Strip spaces and escape newlines. lines = msg_txt.split('\n') lines = [line.strip() for line in lines] - msg_txt = "\\n".join(lines) + msg_txt = "\n".join(lines) self._messages[msg_name] = msg_txt def _ParseGritNodes(self, item): diff --git a/tools/grit/grit/format/policy_templates/writers/adm_writer.py b/tools/grit/grit/format/policy_templates/writers/adm_writer.py index d0639f6..3e094a1 100644 --- a/tools/grit/grit/format/policy_templates/writers/adm_writer.py +++ b/tools/grit/grit/format/policy_templates/writers/adm_writer.py @@ -26,6 +26,8 @@ class AdmWriter(template_writer.TemplateWriter): NEWLINE = '\r\n' def _AddGuiString(self, name, value): + # Escape newlines in the value. + value = value.replace('\n','\\n') line = '%s="%s"' % (name, value) self.str_list.append(line) diff --git a/tools/grit/grit/format/policy_templates/writers/plist_strings_writer.py b/tools/grit/grit/format/policy_templates/writers/plist_strings_writer.py index ce1da45..a1e9e3c 100644 --- a/tools/grit/grit/format/policy_templates/writers/plist_strings_writer.py +++ b/tools/grit/grit/format/policy_templates/writers/plist_strings_writer.py @@ -38,7 +38,7 @@ class PListStringsWriter(template_writer.TemplateWriter): msg = self._policy_group[msg_id] return msg - def _AddToStringTable(self, item_name, title, desc): + def _AddToStringTable(self, item_name, caption, desc): '''Add a title and a description of an item to the string table. Args: @@ -47,9 +47,11 @@ class PListStringsWriter(template_writer.TemplateWriter): title: The text of the title to add. desc: The text of the description to add. ''' - title = title.replace('"', '\\"') + caption = caption.replace('"', '\\"') + caption = caption.replace('\n','\\n') desc = desc.replace('"', '\\"') - self._out.append('%s.pfm_title = \"%s\";' % (item_name, title)) + desc = desc.replace('\n','\\n') + self._out.append('%s.pfm_title = \"%s\";' % (item_name, caption)) self._out.append('%s.pfm_description = \"%s\";' % (item_name, desc)) def WritePolicy(self, policy): @@ -65,8 +67,8 @@ class PListStringsWriter(template_writer.TemplateWriter): # Append the captions of enum items to the description string. item_descs = [] for item in policy['items']: - item_descs.append( item['value'] + ' - ' + item['caption'] ) - desc = '\\n'.join(item_descs) + '\\n' + desc + item_descs.append(item['value'] + ' - ' + item['caption']) + desc = '\n'.join(item_descs) + '\n' + desc self._AddToStringTable(policy['name'], caption, desc) |