diff options
author | joaodasilva@chromium.org <joaodasilva@chromium.org> | 2014-08-28 15:22:41 +0000 |
---|---|---|
committer | joaodasilva@chromium.org <joaodasilva@chromium.org> | 2014-08-28 15:22:41 +0000 |
commit | 0ad0c7e8adfe4d22dfd7c60957e8e4e410c5c33d (patch) | |
tree | 054196a5d116ec9d05a2d32b4dfdd30e207f35ed | |
parent | 206c6aa4450db4e961d20f8367f33df42bba6a85 (diff) | |
download | grit-0ad0c7e8adfe4d22dfd7c60957e8e4e410c5c33d.tar.gz |
Fixed the example JSON strings for Windows and Linux.
The example policies weren't valid JSON because they used single quotes
instead of double quotes.
BUG=None
R=pastarmovj@chromium.org
Review URL: https://codereview.chromium.org/512733004
git-svn-id: http://grit-i18n.googlecode.com/svn/trunk@174 7262f16d-afe8-6277-6482-052fa10e57b1
-rw-r--r-- | grit/format/policy_templates/writers/doc_writer.py | 7 | ||||
-rw-r--r-- | grit/format/policy_templates/writers/doc_writer_unittest.py | 5 |
2 files changed, 7 insertions, 5 deletions
diff --git a/grit/format/policy_templates/writers/doc_writer.py b/grit/format/policy_templates/writers/doc_writer.py index e8543c2..af530f1 100644 --- a/grit/format/policy_templates/writers/doc_writer.py +++ b/grit/format/policy_templates/writers/doc_writer.py @@ -4,6 +4,7 @@ # found in the LICENSE file. +import json from xml.dom import minidom from grit import lazy_re from grit.format.policy_templates.writers import xml_formatted_writer @@ -287,8 +288,8 @@ class DocWriter(xml_formatted_writer.XMLFormattedWriter): self.AddElement(parent, 'dt', {}, 'Windows:') win = self._AddStyledElement(parent, 'dd', ['.monospace', '.pre']) key_name = self.config['win_reg_mandatory_key_name'] - example = str(policy['example_value']) - self.AddText(win, '%s\\%s = "%s"' % (key_name, policy['name'], example)) + example = json.dumps(policy['example_value']) + self.AddText(win, '%s\\%s = %s' % (key_name, policy['name'], example)) def _AddDictionaryExampleLinux(self, parent, policy): '''Adds an example value for Linux of a 'dict' policy to a DOM node. @@ -300,7 +301,7 @@ class DocWriter(xml_formatted_writer.XMLFormattedWriter): ''' self.AddElement(parent, 'dt', {}, 'Linux:') linux = self._AddStyledElement(parent, 'dd', ['.monospace']) - example = str(policy['example_value']) + example = json.dumps(policy['example_value']) self.AddText(linux, '%s: %s' % (policy['name'], example)) def _AddDictionaryExample(self, parent, policy): diff --git a/grit/format/policy_templates/writers/doc_writer_unittest.py b/grit/format/policy_templates/writers/doc_writer_unittest.py index 05ea240..7a71044 100644 --- a/grit/format/policy_templates/writers/doc_writer_unittest.py +++ b/grit/format/policy_templates/writers/doc_writer_unittest.py @@ -6,6 +6,7 @@ '''Unit tests for grit.format.policy_templates.writers.doc_writer''' +import json import os import sys if __name__ == '__main__': @@ -688,14 +689,14 @@ See <a href="http://policy-explanation.example.com">http://policy-explanation.ex }, } self.writer._AddDictionaryExample(self.doc_root, policy) - value = str(policy['example_value']) + value = json.dumps(policy['example_value']).replace('"', '"') self.assertEquals( self.doc_root.toxml(), '<root>' '<dl style="style_dd dl;">' '<dt>Windows:</dt>' '<dd style="style_.monospace;style_.pre;">MockKey\PolicyName = ' - '"' + value + '"' + + value + '</dd>' '<dt>Linux:</dt>' '<dd style="style_.monospace;">PolicyName: ' + value + '</dd>' |