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

Side by Side Diff: grit/format/policy_templates/policy_template_generator.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
« no previous file with comments | « no previous file | grit/format/policy_templates/policy_template_generator_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 copy 7 import copy
8 8
9 9
10 class PolicyTemplateGenerator: 10 class PolicyTemplateGenerator:
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 policy: The data structure of the policy or group, that will get message 111 policy: The data structure of the policy or group, that will get message
112 strings here. 112 strings here.
113 ''' 113 '''
114 policy['desc'] = self._ImportMessage(policy['desc']) 114 policy['desc'] = self._ImportMessage(policy['desc'])
115 policy['caption'] = self._ImportMessage(policy['caption']) 115 policy['caption'] = self._ImportMessage(policy['caption'])
116 if 'label' in policy: 116 if 'label' in policy:
117 policy['label'] = self._ImportMessage(policy['label']) 117 policy['label'] = self._ImportMessage(policy['label'])
118 118
119 if policy['type'] == 'group': 119 if policy['type'] == 'group':
120 self._ProcessPolicyList(policy['policies']) 120 self._ProcessPolicyList(policy['policies'])
121 elif policy['type'] in ('string-enum', 'int-enum'): 121 elif policy['type'] in ('string-enum', 'int-enum', 'string-enum-list'):
122 # Iterate through all the items of an enum-type policy, and add captions. 122 # Iterate through all the items of an enum-type policy, and add captions.
123 for item in policy['items']: 123 for item in policy['items']:
124 item['caption'] = self._ImportMessage(item['caption']) 124 item['caption'] = self._ImportMessage(item['caption'])
125 if policy['type'] != 'group': 125 if policy['type'] != 'group':
126 if not 'label' in policy: 126 if not 'label' in policy:
127 # If 'label' is not specified, then it defaults to 'caption': 127 # If 'label' is not specified, then it defaults to 'caption':
128 policy['label'] = policy['caption'] 128 policy['label'] = policy['caption']
129 policy['supported_on'] = self._ProcessSupportedOn(policy['supported_on']) 129 policy['supported_on'] = self._ProcessSupportedOn(policy['supported_on'])
130 130
131 def _ProcessPolicyList(self, policy_list): 131 def _ProcessPolicyList(self, policy_list):
(...skipping 13 matching lines...) Expand all
145 to the constructor, using a given TemplateWriter. 145 to the constructor, using a given TemplateWriter.
146 146
147 Args: 147 Args:
148 template_writer: An object implementing TemplateWriter. Its methods 148 template_writer: An object implementing TemplateWriter. Its methods
149 are called here for each item of self._policy_groups. 149 are called here for each item of self._policy_groups.
150 150
151 Returns: 151 Returns:
152 The text of the generated template. 152 The text of the generated template.
153 ''' 153 '''
154 return template_writer.WriteTemplate(self._policy_data) 154 return template_writer.WriteTemplate(self._policy_data)
OLDNEW
« no previous file with comments | « no previous file | grit/format/policy_templates/policy_template_generator_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698