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

Side by Side Diff: grit/format/policy_templates/writers/doc_writer.py

Issue 512733004: Fixed the example JSON strings for Windows and Linux. (Closed) Base URL: http://grit-i18n.googlecode.com/svn/trunk/
Patch Set: Created 6 years, 3 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | grit/format/policy_templates/writers/doc_writer_unittest.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 6
7 import json
7 from xml.dom import minidom 8 from xml.dom import minidom
8 from grit import lazy_re 9 from grit import lazy_re
9 from grit.format.policy_templates.writers import xml_formatted_writer 10 from grit.format.policy_templates.writers import xml_formatted_writer
10 11
11 12
12 def GetWriter(config): 13 def GetWriter(config):
13 '''Factory method for creating DocWriter objects. 14 '''Factory method for creating DocWriter objects.
14 See the constructor of TemplateWriter for description of 15 See the constructor of TemplateWriter for description of
15 arguments. 16 arguments.
16 ''' 17 '''
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 '''Adds an example value for Windows of a 'dict' policy to a DOM node. 281 '''Adds an example value for Windows of a 'dict' policy to a DOM node.
281 282
282 Args: 283 Args:
283 parent: The DOM node for which the example will be added. 284 parent: The DOM node for which the example will be added.
284 policy: A policy of type 'dict', for which the Windows example value 285 policy: A policy of type 'dict', for which the Windows example value
285 is generated. 286 is generated.
286 ''' 287 '''
287 self.AddElement(parent, 'dt', {}, 'Windows:') 288 self.AddElement(parent, 'dt', {}, 'Windows:')
288 win = self._AddStyledElement(parent, 'dd', ['.monospace', '.pre']) 289 win = self._AddStyledElement(parent, 'dd', ['.monospace', '.pre'])
289 key_name = self.config['win_reg_mandatory_key_name'] 290 key_name = self.config['win_reg_mandatory_key_name']
290 example = str(policy['example_value']) 291 example = json.dumps(policy['example_value'])
291 self.AddText(win, '%s\\%s = "%s"' % (key_name, policy['name'], example)) 292 self.AddText(win, '%s\\%s = %s' % (key_name, policy['name'], example))
292 293
293 def _AddDictionaryExampleLinux(self, parent, policy): 294 def _AddDictionaryExampleLinux(self, parent, policy):
294 '''Adds an example value for Linux of a 'dict' policy to a DOM node. 295 '''Adds an example value for Linux of a 'dict' policy to a DOM node.
295 296
296 Args: 297 Args:
297 parent: The DOM node for which the example will be added. 298 parent: The DOM node for which the example will be added.
298 policy: A policy of type 'dict', for which the Linux example value 299 policy: A policy of type 'dict', for which the Linux example value
299 is generated. 300 is generated.
300 ''' 301 '''
301 self.AddElement(parent, 'dt', {}, 'Linux:') 302 self.AddElement(parent, 'dt', {}, 'Linux:')
302 linux = self._AddStyledElement(parent, 'dd', ['.monospace']) 303 linux = self._AddStyledElement(parent, 'dd', ['.monospace'])
303 example = str(policy['example_value']) 304 example = json.dumps(policy['example_value'])
304 self.AddText(linux, '%s: %s' % (policy['name'], example)) 305 self.AddText(linux, '%s: %s' % (policy['name'], example))
305 306
306 def _AddDictionaryExample(self, parent, policy): 307 def _AddDictionaryExample(self, parent, policy):
307 '''Adds the example value of a 'dict' policy to a DOM node. Example output: 308 '''Adds the example value of a 'dict' policy to a DOM node. Example output:
308 <dl> 309 <dl>
309 <dt>Windows:</dt> 310 <dt>Windows:</dt>
310 <dd> 311 <dd>
311 Software\Policies\Chromium\ProxySettings = "{ 'ProxyMode': 'direct' }" 312 Software\Policies\Chromium\ProxySettings = "{ 'ProxyMode': 'direct' }"
312 </dd> 313 </dd>
313 <dt>Linux:</dt> 314 <dt>Linux:</dt>
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
674 } 675 }
675 676
676 # A simple regexp to search for URLs. It is enough for now. 677 # A simple regexp to search for URLs. It is enough for now.
677 self._url_matcher = lazy_re.compile('(http://[^\\s]*[^\\s\\.])') 678 self._url_matcher = lazy_re.compile('(http://[^\\s]*[^\\s\\.])')
678 679
679 def GetTemplateText(self): 680 def GetTemplateText(self):
680 # Return the text representation of the main <div> tag. 681 # Return the text representation of the main <div> tag.
681 return self._main_div.toxml() 682 return self._main_div.toxml()
682 # To get a complete HTML file, use the following. 683 # To get a complete HTML file, use the following.
683 # return self._doc.toxml() 684 # return self._doc.toxml()
OLDNEW
« no previous file with comments | « no previous file | grit/format/policy_templates/writers/doc_writer_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698