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

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

Issue 687073003: Set the MAXLEN/maxLength attribute for strings in ADM[X] templates. (Closed) Base URL: http://grit-i18n.googlecode.com/svn/trunk/
Patch Set: Created 6 years, 1 month 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/adm_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 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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 if policy['type'] in ('list', 'string-enum-list'): 115 if policy['type'] in ('list', 'string-enum-list'):
116 # Note that the following line causes FullArmor ADMX Migrator to create 116 # Note that the following line causes FullArmor ADMX Migrator to create
117 # corrupt ADMX files. Please use admx_writer to get ADMX files. 117 # corrupt ADMX files. Please use admx_writer to get ADMX files.
118 builder.AddLine('KEYNAME "%s\\%s"' % (key_name, policy['name'])) 118 builder.AddLine('KEYNAME "%s\\%s"' % (key_name, policy['name']))
119 builder.AddLine('VALUEPREFIX ""') 119 builder.AddLine('VALUEPREFIX ""')
120 else: 120 else:
121 builder.AddLine('VALUENAME "%s"' % policy['name']) 121 builder.AddLine('VALUENAME "%s"' % policy['name'])
122 if policy['type'] == 'int': 122 if policy['type'] == 'int':
123 # The default max for NUMERIC values is 9999 which is too small for us. 123 # The default max for NUMERIC values is 9999 which is too small for us.
124 builder.AddLine('MIN 0 MAX 2000000000') 124 builder.AddLine('MIN 0 MAX 2000000000')
125 if policy['type'] in ('string', 'dict'):
126 # The default max for EDITTEXT values is 1023, which is too small for
127 # big JSON blobs and other string policies.
128 builder.AddLine('MAXLEN 1000000')
125 if policy['type'] in ('int-enum', 'string-enum'): 129 if policy['type'] in ('int-enum', 'string-enum'):
126 builder.AddLine('ITEMLIST', 1) 130 builder.AddLine('ITEMLIST', 1)
127 for item in policy['items']: 131 for item in policy['items']:
128 if policy['type'] == 'int-enum': 132 if policy['type'] == 'int-enum':
129 value_text = 'NUMERIC ' + str(item['value']) 133 value_text = 'NUMERIC ' + str(item['value'])
130 else: 134 else:
131 value_text = '"' + item['value'] + '"' 135 value_text = '"' + item['value'] + '"'
132 string_id = self._Escape(item['name'] + '_DropDown') 136 string_id = self._Escape(item['name'] + '_DropDown')
133 builder.AddLine('NAME !!%s VALUE %s' % (string_id, value_text)) 137 builder.AddLine('NAME !!%s VALUE %s' % (string_id, value_text))
134 self._AddGuiString(string_id, item['caption']) 138 self._AddGuiString(string_id, item['caption'])
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 self.strings = IndentedStringBuilder() 265 self.strings = IndentedStringBuilder()
262 # Map of strings seen, to avoid duplicates. 266 # Map of strings seen, to avoid duplicates.
263 self.strings_seen = {} 267 self.strings_seen = {}
264 # String buffer for building the policies of the ADM file. 268 # String buffer for building the policies of the ADM file.
265 self.policies = IndentedStringBuilder() 269 self.policies = IndentedStringBuilder()
266 # String buffer for building the recommended policies of the ADM file. 270 # String buffer for building the recommended policies of the ADM file.
267 self.recommended_policies = IndentedStringBuilder() 271 self.recommended_policies = IndentedStringBuilder()
268 272
269 def GetTemplateText(self): 273 def GetTemplateText(self):
270 return self.lines.ToString() 274 return self.lines.ToString()
OLDNEW
« no previous file with comments | « no previous file | grit/format/policy_templates/writers/adm_writer_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698