OLD | NEW |
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 import types | 8 import types |
9 | 9 |
10 | 10 |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 elif policy['type'] in ('string-enum', 'int-enum'): | 141 elif policy['type'] in ('string-enum', 'int-enum'): |
142 # Iterate through all the items of an enum-type policy, and add captions. | 142 # Iterate through all the items of an enum-type policy, and add captions. |
143 for item in policy['items']: | 143 for item in policy['items']: |
144 item['caption'] = self._ImportMessage(item['caption']) | 144 item['caption'] = self._ImportMessage(item['caption']) |
145 elif policy['type'] == 'dict' and 'example_value' in policy: | 145 elif policy['type'] == 'dict' and 'example_value' in policy: |
146 policy['example_value'] = self._PrintPolicyValue(policy['example_value']) | 146 policy['example_value'] = self._PrintPolicyValue(policy['example_value']) |
147 if policy['type'] != 'group': | 147 if policy['type'] != 'group': |
148 if not 'label' in policy: | 148 if not 'label' in policy: |
149 # If 'label' is not specified, then it defaults to 'caption': | 149 # If 'label' is not specified, then it defaults to 'caption': |
150 policy['label'] = policy['caption'] | 150 policy['label'] = policy['caption'] |
151 policy['supported_on'] = self._ProcessSupportedOn( | 151 policy['supported_on'] = self._ProcessSupportedOn(policy['supported_on']) |
152 policy['supported_on']) | |
153 | 152 |
154 def _ProcessPolicyList(self, policy_list): | 153 def _ProcessPolicyList(self, policy_list): |
155 '''Adds localized message strings to each item in a list of policies and | 154 '''Adds localized message strings to each item in a list of policies and |
156 groups. Also breaks up the content of 'supported_on' attributes into lists | 155 groups. Also breaks up the content of 'supported_on' attributes into lists |
157 of dictionaries. | 156 of dictionaries. |
158 | 157 |
159 Args: | 158 Args: |
160 policy_list: A list of policies and groups. Message strings will be added | 159 policy_list: A list of policies and groups. Message strings will be added |
161 for each item and to their child items, recursively. | 160 for each item and to their child items, recursively. |
162 ''' | 161 ''' |
163 for policy in policy_list: | 162 for policy in policy_list: |
164 self._ProcessPolicy(policy) | 163 self._ProcessPolicy(policy) |
165 | 164 |
166 def GetTemplateText(self, template_writer): | 165 def GetTemplateText(self, template_writer): |
167 '''Generates the text of the template from the arguments given | 166 '''Generates the text of the template from the arguments given |
168 to the constructor, using a given TemplateWriter. | 167 to the constructor, using a given TemplateWriter. |
169 | 168 |
170 Args: | 169 Args: |
171 template_writer: An object implementing TemplateWriter. Its methods | 170 template_writer: An object implementing TemplateWriter. Its methods |
172 are called here for each item of self._policy_groups. | 171 are called here for each item of self._policy_groups. |
173 | 172 |
174 Returns: | 173 Returns: |
175 The text of the generated template. | 174 The text of the generated template. |
176 ''' | 175 ''' |
177 return template_writer.WriteTemplate(self._policy_data) | 176 return template_writer.WriteTemplate(self._policy_data) |
OLD | NEW |