| 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 | 8 |
| 9 | 9 |
| 10 class PolicyTemplateGenerator: | 10 class PolicyTemplateGenerator: |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 Loading... |
| 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) |
| OLD | NEW |