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

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

Issue 6134006: Integrate user strings into the JSON policy template file (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: " Created 9 years, 11 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
OLDNEW
1 # Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 5
6 import re 6 import re
7 7
8 from xml.dom import minidom 8 from xml.dom import minidom
9 from grit.format.policy_templates.writers import xml_formatted_writer 9 from grit.format.policy_templates.writers import xml_formatted_writer
10 10
11 11
12 def GetWriter(config, messages): 12 def GetWriter(config):
13 '''Factory method for creating DocWriter objects. 13 '''Factory method for creating DocWriter objects.
14 See the constructor of TemplateWriter for description of 14 See the constructor of TemplateWriter for description of
15 arguments. 15 arguments.
16 ''' 16 '''
17 return DocWriter(['*'], config, messages) 17 return DocWriter(['*'], config)
18 18
19 19
20 class DocWriter(xml_formatted_writer.XMLFormattedWriter): 20 class DocWriter(xml_formatted_writer.XMLFormattedWriter):
21 '''Class for generating policy templates in HTML format. 21 '''Class for generating policy templates in HTML format.
22 The intended use of the generated file is to upload it on 22 The intended use of the generated file is to upload it on
23 http://dev.chromium.org, therefore its format has some limitations: 23 http://dev.chromium.org, therefore its format has some limitations:
24 - No HTML and body tags. 24 - No HTML and body tags.
25 - Restricted set of element attributes: for example no 'class'. 25 - Restricted set of element attributes: for example no 'class'.
26 Because of the latter the output is styled using the 'style' 26 Because of the latter the output is styled using the 'style'
27 attributes of HTML elements. This is supported by the dictionary 27 attributes of HTML elements. This is supported by the dictionary
28 self._STYLES[] and the method self._AddStyledElement(), they try 28 self._STYLES[] and the method self._AddStyledElement(), they try
29 to mimic the functionality of CSS classes. (But without inheritance.) 29 to mimic the functionality of CSS classes. (But without inheritance.)
30 30
31 This class is invoked by PolicyTemplateGenerator to create the HTML 31 This class is invoked by PolicyTemplateGenerator to create the HTML
32 files. 32 files.
33 ''' 33 '''
34 34
35 def _GetLocalizedMessage(self, msg_id): 35 def _GetLocalizedMessage(self, msg_id):
36 '''Returns a localized message for this writer. 36 '''Returns a localized message for this writer.
37 37
38 Args: 38 Args:
39 msg_id: The identifier of the message. 39 msg_id: The identifier of the message.
40 40
41 Returns: 41 Returns:
42 The localized message. 42 The localized message.
43 ''' 43 '''
44 return self.messages['IDS_POLICY_DOC_' + msg_id.upper()] 44 return self.messages['doc_' + msg_id]['text']
45 45
46 def _MapListToString(self, item_map, items): 46 def _MapListToString(self, item_map, items):
47 '''Creates a comma-separated list. 47 '''Creates a comma-separated list.
48 48
49 Args: 49 Args:
50 item_map: A dictionary containing all the elements of 'items' as 50 item_map: A dictionary containing all the elements of 'items' as
51 keys. 51 keys.
52 items: A list of arbitrary items. 52 items: A list of arbitrary items.
53 53
54 Returns: 54 Returns:
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after
515 } 515 }
516 516
517 # A simple regexp to search for URLs. It is enough for now. 517 # A simple regexp to search for URLs. It is enough for now.
518 self._url_matcher = re.compile('(http://[^\\s]*[^\\s\\.])') 518 self._url_matcher = re.compile('(http://[^\\s]*[^\\s\\.])')
519 519
520 def GetTemplateText(self): 520 def GetTemplateText(self):
521 # Return the text representation of the main <div> tag. 521 # Return the text representation of the main <div> tag.
522 return self._main_div.toxml() 522 return self._main_div.toxml()
523 # To get a complete HTML file, use the following. 523 # To get a complete HTML file, use the following.
524 # return self._doc.toxml() 524 # return self._doc.toxml()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698