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

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

Issue 6176005: Support int-typed policies in policy template generator (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) 2011 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 from grit.format.policy_templates.writers import template_writer 6 from grit.format.policy_templates.writers import template_writer
7 7
8 8
9 def GetWriter(config, messages): 9 def GetWriter(config, messages):
10 '''Factory method for creating AdmWriter objects. 10 '''Factory method for creating AdmWriter objects.
11 See the constructor of TemplateWriter for description of 11 See the constructor of TemplateWriter for description of
12 arguments. 12 arguments.
13 ''' 13 '''
14 return AdmWriter(['win'], config, messages) 14 return AdmWriter(['win'], config, messages)
15 15
16 16
17 class AdmWriter(template_writer.TemplateWriter): 17 class AdmWriter(template_writer.TemplateWriter):
18 '''Class for generating policy templates in Windows ADM format. 18 '''Class for generating policy templates in Windows ADM format.
19 It is used by PolicyTemplateGenerator to write ADM files. 19 It is used by PolicyTemplateGenerator to write ADM files.
20 ''' 20 '''
21 21
22 TYPE_TO_INPUT = { 22 TYPE_TO_INPUT = {
23 'string': 'EDITTEXT', 23 'string': 'EDITTEXT',
24 'int': 'NUMERIC',
24 'string-enum': 'DROPDOWNLIST', 25 'string-enum': 'DROPDOWNLIST',
25 'int-enum': 'DROPDOWNLIST', 26 'int-enum': 'DROPDOWNLIST',
26 'list': 'LISTBOX'} 27 'list': 'LISTBOX'}
27 NEWLINE = '\r\n' 28 NEWLINE = '\r\n'
28 29
29 def _AddGuiString(self, name, value): 30 def _AddGuiString(self, name, value):
30 # Escape newlines in the value. 31 # Escape newlines in the value.
31 value = value.replace('\n','\\n') 32 value = value.replace('\n', '\\n')
32 line = '%s="%s"' % (name, value) 33 line = '%s="%s"' % (name, value)
33 self.str_list.append(line) 34 self.str_list.append(line)
34 35
35 def _PrintLine(self, string='', indent_diff=0): 36 def _PrintLine(self, string='', indent_diff=0):
36 '''Prints a string with indents and a linebreak to the output. 37 '''Prints a string with indents and a linebreak to the output.
37 38
38 Args: 39 Args:
39 string: The string to print. 40 string: The string to print.
40 indent_diff: the difference of indentation of the printed line, 41 indent_diff: the difference of indentation of the printed line,
41 compared to the next/previous printed line. Increment occurs 42 compared to the next/previous printed line. Increment occurs
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 self._PrintLine('', -1) 150 self._PrintLine('', -1)
150 151
151 def Init(self): 152 def Init(self):
152 self.policy_list = [] 153 self.policy_list = []
153 self.str_list = ['[Strings]'] 154 self.str_list = ['[Strings]']
154 self.indent = '' 155 self.indent = ''
155 156
156 def GetTemplateText(self): 157 def GetTemplateText(self):
157 lines = self.policy_list + self.str_list 158 lines = self.policy_list + self.str_list
158 return self.NEWLINE.join(lines) 159 return self.NEWLINE.join(lines)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698