OLD | NEW |
1 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 | 5 |
6 from xml.dom import minidom | 6 from xml.dom import minidom |
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, messages): | 10 def GetWriter(config, messages): |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 else: | 62 else: |
63 self._StartBlock(None) | 63 self._StartBlock(None) |
64 if policy['type'] == 'string': | 64 if policy['type'] == 'string': |
65 escaped_str = self._EscapeRegString(example_value) | 65 escaped_str = self._EscapeRegString(example_value) |
66 example_value_str = '"' + escaped_str + '"' | 66 example_value_str = '"' + escaped_str + '"' |
67 elif policy['type'] == 'main': | 67 elif policy['type'] == 'main': |
68 if example_value == True: | 68 if example_value == True: |
69 example_value_str = 'dword:1' | 69 example_value_str = 'dword:1' |
70 else: | 70 else: |
71 example_value_str = 'dword:0' | 71 example_value_str = 'dword:0' |
72 elif policy['type'] == 'enum': | 72 elif policy['type'] == 'int-enum': |
73 example_value_str = 'dword:%d' % example_value | 73 example_value_str = 'dword:%d' % example_value |
| 74 elif policy['type'] == 'string-enum': |
| 75 example_value_str = '"%s"' % example_value |
74 else: | 76 else: |
75 raise Exception('unknown policy type %s:' % policy['type']) | 77 raise Exception('unknown policy type %s:' % policy['type']) |
76 | 78 |
77 self._out.append('"%s"=%s' % (policy['name'], example_value_str)) | 79 self._out.append('"%s"=%s' % (policy['name'], example_value_str)) |
78 | 80 |
79 def BeginTemplate(self): | 81 def BeginTemplate(self): |
80 pass | 82 pass |
81 | 83 |
82 def EndTemplate(self): | 84 def EndTemplate(self): |
83 pass | 85 pass |
84 | 86 |
85 def Init(self): | 87 def Init(self): |
86 self._out = ['Windows Registry Editor Version 5.00'] | 88 self._out = ['Windows Registry Editor Version 5.00'] |
87 self._last_key = None | 89 self._last_key = None |
88 | 90 |
89 def GetTemplateText(self): | 91 def GetTemplateText(self): |
90 return self.NEWLINE.join(self._out) | 92 return self.NEWLINE.join(self._out) |
OLD | NEW |