| 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 json | 7 import json |
| 8 | 8 |
| 9 from grit.format.policy_templates.writers import template_writer | 9 from grit.format.policy_templates.writers import template_writer |
| 10 | 10 |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 else: | 76 else: |
| 77 example_value_str = 'dword:00000000' | 77 example_value_str = 'dword:00000000' |
| 78 elif policy['type'] in ('int', 'int-enum'): | 78 elif policy['type'] in ('int', 'int-enum'): |
| 79 example_value_str = 'dword:%08x' % example_value | 79 example_value_str = 'dword:%08x' % example_value |
| 80 else: | 80 else: |
| 81 raise Exception('unknown policy type %s:' % policy['type']) | 81 raise Exception('unknown policy type %s:' % policy['type']) |
| 82 | 82 |
| 83 list.append('"%s"=%s' % (policy['name'], example_value_str)) | 83 list.append('"%s"=%s' % (policy['name'], example_value_str)) |
| 84 | 84 |
| 85 def WritePolicy(self, policy): | 85 def WritePolicy(self, policy): |
| 86 self._WritePolicy(policy, | 86 if self.CanBeMandatory(policy): |
| 87 self.config['win_reg_mandatory_key_name'], | 87 self._WritePolicy(policy, |
| 88 self._mandatory) | 88 self.config['win_reg_mandatory_key_name'], |
| 89 self._mandatory) |
| 89 | 90 |
| 90 def WriteRecommendedPolicy(self, policy): | 91 def WriteRecommendedPolicy(self, policy): |
| 91 self._WritePolicy(policy, | 92 self._WritePolicy(policy, |
| 92 self.config['win_reg_recommended_key_name'], | 93 self.config['win_reg_recommended_key_name'], |
| 93 self._recommended) | 94 self._recommended) |
| 94 | 95 |
| 95 def BeginTemplate(self): | 96 def BeginTemplate(self): |
| 96 pass | 97 pass |
| 97 | 98 |
| 98 def EndTemplate(self): | 99 def EndTemplate(self): |
| 99 pass | 100 pass |
| 100 | 101 |
| 101 def Init(self): | 102 def Init(self): |
| 102 self._mandatory = [] | 103 self._mandatory = [] |
| 103 self._recommended = [] | 104 self._recommended = [] |
| 104 self._last_key = {} | 105 self._last_key = {} |
| 105 | 106 |
| 106 def GetTemplateText(self): | 107 def GetTemplateText(self): |
| 107 prefix = ['Windows Registry Editor Version 5.00'] | 108 prefix = ['Windows Registry Editor Version 5.00'] |
| 108 all = prefix + self._mandatory + self._recommended | 109 all = prefix + self._mandatory + self._recommended |
| 109 return self.NEWLINE.join(all) | 110 return self.NEWLINE.join(all) |
| OLD | NEW |