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

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

Issue 347293003: Added support for string-enum-list. (Closed) Base URL: http://grit-i18n.googlecode.com/svn/trunk/
Patch Set: Created 6 years, 5 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 #!/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 from grit.format.policy_templates.writers import template_writer 7 from grit.format.policy_templates.writers import template_writer
8 8
9 9
10 NEWLINE = '\r\n' 10 NEWLINE = '\r\n'
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 '''Class for generating policy templates in Windows ADM format. 64 '''Class for generating policy templates in Windows ADM format.
65 It is used by PolicyTemplateGenerator to write ADM files. 65 It is used by PolicyTemplateGenerator to write ADM files.
66 ''' 66 '''
67 67
68 TYPE_TO_INPUT = { 68 TYPE_TO_INPUT = {
69 'string': 'EDITTEXT', 69 'string': 'EDITTEXT',
70 'int': 'NUMERIC', 70 'int': 'NUMERIC',
71 'string-enum': 'DROPDOWNLIST', 71 'string-enum': 'DROPDOWNLIST',
72 'int-enum': 'DROPDOWNLIST', 72 'int-enum': 'DROPDOWNLIST',
73 'list': 'LISTBOX', 73 'list': 'LISTBOX',
74 'string-enum-list': 'LISTBOX',
74 'dict': 'EDITTEXT' 75 'dict': 'EDITTEXT'
75 } 76 }
76 77
77 def _AddGuiString(self, name, value): 78 def _AddGuiString(self, name, value):
78 # Escape newlines in the value. 79 # Escape newlines in the value.
79 value = value.replace('\n', '\\n') 80 value = value.replace('\n', '\\n')
80 if name in self.strings_seen: 81 if name in self.strings_seen:
81 err = ('%s was added as "%s" and now added again as "%s"' % 82 err = ('%s was added as "%s" and now added again as "%s"' %
82 (name, self.strings_seen[name], value)) 83 (name, self.strings_seen[name], value))
83 assert value == self.strings_seen[name], err 84 assert value == self.strings_seen[name], err
(...skipping 15 matching lines...) Expand all
99 key_name: The registry key backing the policy. 100 key_name: The registry key backing the policy.
100 builder: Builder to append lines to. 101 builder: Builder to append lines to.
101 ''' 102 '''
102 policy_part_name = policy['name'] + '_Part' 103 policy_part_name = policy['name'] + '_Part'
103 self._AddGuiString(policy_part_name, policy['label']) 104 self._AddGuiString(policy_part_name, policy['label'])
104 105
105 # Print the PART ... END PART section: 106 # Print the PART ... END PART section:
106 builder.AddLine() 107 builder.AddLine()
107 adm_type = self.TYPE_TO_INPUT[policy['type']] 108 adm_type = self.TYPE_TO_INPUT[policy['type']]
108 builder.AddLine('PART !!%s %s' % (policy_part_name, adm_type), 1) 109 builder.AddLine('PART !!%s %s' % (policy_part_name, adm_type), 1)
109 if policy['type'] == 'list': 110 if policy['type'] in ('list', 'string-enum-list'):
110 # Note that the following line causes FullArmor ADMX Migrator to create 111 # Note that the following line causes FullArmor ADMX Migrator to create
111 # corrupt ADMX files. Please use admx_writer to get ADMX files. 112 # corrupt ADMX files. Please use admx_writer to get ADMX files.
112 builder.AddLine('KEYNAME "%s\\%s"' % (key_name, policy['name'])) 113 builder.AddLine('KEYNAME "%s\\%s"' % (key_name, policy['name']))
113 builder.AddLine('VALUEPREFIX ""') 114 builder.AddLine('VALUEPREFIX ""')
114 else: 115 else:
115 builder.AddLine('VALUENAME "%s"' % policy['name']) 116 builder.AddLine('VALUENAME "%s"' % policy['name'])
116 if policy['type'] == 'int': 117 if policy['type'] == 'int':
117 # The default max for NUMERIC values is 9999 which is too small for us. 118 # The default max for NUMERIC values is 9999 which is too small for us.
118 builder.AddLine('MIN 0 MAX 2000000000') 119 builder.AddLine('MIN 0 MAX 2000000000')
119 if policy['type'] in ('int-enum', 'string-enum'): 120 if policy['type'] in ('int-enum', 'string-enum'):
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 self.strings = IndentedStringBuilder() 248 self.strings = IndentedStringBuilder()
248 # Map of strings seen, to avoid duplicates. 249 # Map of strings seen, to avoid duplicates.
249 self.strings_seen = {} 250 self.strings_seen = {}
250 # String buffer for building the policies of the ADM file. 251 # String buffer for building the policies of the ADM file.
251 self.policies = IndentedStringBuilder() 252 self.policies = IndentedStringBuilder()
252 # String buffer for building the recommended policies of the ADM file. 253 # String buffer for building the recommended policies of the ADM file.
253 self.recommended_policies = IndentedStringBuilder() 254 self.recommended_policies = IndentedStringBuilder()
254 255
255 def GetTemplateText(self): 256 def GetTemplateText(self):
256 return self.lines.ToString() 257 return self.lines.ToString()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698