| 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 import json | 6 import json |
| 7 | 7 |
| 8 from textwrap import TextWrapper | 8 from textwrap import TextWrapper |
| 9 from grit.format.policy_templates.writers import template_writer | 9 from grit.format.policy_templates.writers import template_writer |
| 10 | 10 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 def WritePolicy(self, policy): | 42 def WritePolicy(self, policy): |
| 43 if policy['type'] == 'external': | 43 if policy['type'] == 'external': |
| 44 # This type can only be set through cloud policy. | 44 # This type can only be set through cloud policy. |
| 45 return | 45 return |
| 46 example_value_str = json.dumps(policy['example_value'], sort_keys=True) | 46 example_value_str = json.dumps(policy['example_value'], sort_keys=True) |
| 47 | 47 |
| 48 # Add comma to the end of the previous line. | 48 # Add comma to the end of the previous line. |
| 49 if not self._first_written: | 49 if not self._first_written: |
| 50 self._out[-2] += ',' | 50 self._out[-2] += ',' |
| 51 | 51 |
| 52 if not self.CanBeMandatory(policy) and self.CanBeRecommended(policy): |
| 53 line = ' // Note: this policy is supported only in recommended mode.' |
| 54 self._out.append(line) |
| 55 line = ' // The JSON file should be placed in %srecommended.' % \ |
| 56 self.config['linux_policy_path'] |
| 57 self._out.append(line) |
| 58 |
| 52 line = ' // %s' % policy['caption'] | 59 line = ' // %s' % policy['caption'] |
| 53 self._out.append(line) | 60 self._out.append(line) |
| 54 self._out.append(HEADER_DELIMETER) | 61 self._out.append(HEADER_DELIMETER) |
| 55 description = self._text_wrapper.wrap(policy['desc']) | 62 description = self._text_wrapper.wrap(policy['desc']) |
| 56 self._out += description; | 63 self._out += description; |
| 57 line = ' //"%s": %s' % (policy['name'], example_value_str) | 64 line = ' //"%s": %s' % (policy['name'], example_value_str) |
| 58 self._out.append('') | 65 self._out.append('') |
| 59 self._out.append(line) | 66 self._out.append(line) |
| 60 self._out.append('') | 67 self._out.append('') |
| 61 | 68 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 73 self._first_written = True | 80 self._first_written = True |
| 74 # Create the TextWrapper object once. | 81 # Create the TextWrapper object once. |
| 75 self._text_wrapper = TextWrapper( | 82 self._text_wrapper = TextWrapper( |
| 76 initial_indent = ' // ', | 83 initial_indent = ' // ', |
| 77 subsequent_indent = ' // ', | 84 subsequent_indent = ' // ', |
| 78 break_long_words = False, | 85 break_long_words = False, |
| 79 width = 80) | 86 width = 80) |
| 80 | 87 |
| 81 def GetTemplateText(self): | 88 def GetTemplateText(self): |
| 82 return '\n'.join(self._out) | 89 return '\n'.join(self._out) |
| OLD | NEW |