| 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 from grit.format.policy_templates.writers import template_writer | 7 from grit.format.policy_templates.writers import template_writer |
| 8 | 8 |
| 9 | 9 |
| 10 def GetWriter(config): | 10 def GetWriter(config): |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 list.sort() methods to sort policies. | 45 list.sort() methods to sort policies. |
| 46 See TemplateWriter.SortPoliciesGroupsFirst for usage. | 46 See TemplateWriter.SortPoliciesGroupsFirst for usage. |
| 47 ''' | 47 ''' |
| 48 is_list = policy['type'] == 'list' | 48 is_list = policy['type'] == 'list' |
| 49 # Lists come after regular policies. | 49 # Lists come after regular policies. |
| 50 return (is_list, policy['name']) | 50 return (is_list, policy['name']) |
| 51 | 51 |
| 52 def _WritePolicy(self, policy, key, list): | 52 def _WritePolicy(self, policy, key, list): |
| 53 example_value = policy['example_value'] | 53 example_value = policy['example_value'] |
| 54 | 54 |
| 55 if policy['type'] == 'list': | 55 if policy['type'] == 'external': |
| 56 # This type can only be set through cloud policy. |
| 57 return |
| 58 elif policy['type'] == 'list': |
| 56 self._StartBlock(key, policy['name'], list) | 59 self._StartBlock(key, policy['name'], list) |
| 57 i = 1 | 60 i = 1 |
| 58 for item in example_value: | 61 for item in example_value: |
| 59 escaped_str = self._EscapeRegString(item) | 62 escaped_str = self._EscapeRegString(item) |
| 60 list.append('"%d"="%s"' % (i, escaped_str)) | 63 list.append('"%d"="%s"' % (i, escaped_str)) |
| 61 i = i + 1 | 64 i = i + 1 |
| 62 else: | 65 else: |
| 63 self._StartBlock(key, None, list) | 66 self._StartBlock(key, None, list) |
| 64 if policy['type'] in ('string', 'dict'): | 67 if policy['type'] in ('string', 'dict'): |
| 65 escaped_str = self._EscapeRegString(str(example_value)) | 68 escaped_str = self._EscapeRegString(str(example_value)) |
| (...skipping 30 matching lines...) Expand all Loading... |
| 96 | 99 |
| 97 def Init(self): | 100 def Init(self): |
| 98 self._mandatory = [] | 101 self._mandatory = [] |
| 99 self._recommended = [] | 102 self._recommended = [] |
| 100 self._last_key = {} | 103 self._last_key = {} |
| 101 | 104 |
| 102 def GetTemplateText(self): | 105 def GetTemplateText(self): |
| 103 prefix = ['Windows Registry Editor Version 5.00'] | 106 prefix = ['Windows Registry Editor Version 5.00'] |
| 104 all = prefix + self._mandatory + self._recommended | 107 all = prefix + self._mandatory + self._recommended |
| 105 return self.NEWLINE.join(all) | 108 return self.NEWLINE.join(all) |
| OLD | NEW |