| 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 writers import template_writer | 9 from writers import template_writer |
| 10 | 10 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 files. | 36 files. |
| 37 ''' | 37 ''' |
| 38 | 38 |
| 39 def PreprocessPolicies(self, policy_list): | 39 def PreprocessPolicies(self, policy_list): |
| 40 return self.FlattenGroupsAndSortPolicies(policy_list) | 40 return self.FlattenGroupsAndSortPolicies(policy_list) |
| 41 | 41 |
| 42 def WriteComment(self, comment): | 42 def WriteComment(self, comment): |
| 43 self._out.append('// ' + comment) | 43 self._out.append('// ' + comment) |
| 44 | 44 |
| 45 def WritePolicy(self, policy): | 45 def WritePolicy(self, policy): |
| 46 if policy['type'] == 'external': | |
| 47 # This type can only be set through cloud policy. | |
| 48 return | |
| 49 example_value_str = json.dumps(policy['example_value'], sort_keys=True) | 46 example_value_str = json.dumps(policy['example_value'], sort_keys=True) |
| 50 | 47 |
| 51 # Add comma to the end of the previous line. | 48 # Add comma to the end of the previous line. |
| 52 if not self._first_written: | 49 if not self._first_written: |
| 53 self._out[-2] += ',' | 50 self._out[-2] += ',' |
| 54 | 51 |
| 55 if not self.CanBeMandatory(policy) and self.CanBeRecommended(policy): | 52 if not self.CanBeMandatory(policy) and self.CanBeRecommended(policy): |
| 56 line = ' // Note: this policy is supported only in recommended mode.' | 53 line = ' // Note: this policy is supported only in recommended mode.' |
| 57 self._out.append(line) | 54 self._out.append(line) |
| 58 line = ' // The JSON file should be placed in %srecommended.' % \ | 55 line = ' // The JSON file should be placed in %srecommended.' % \ |
| (...skipping 27 matching lines...) Expand all Loading... |
| 86 self._first_written = True | 83 self._first_written = True |
| 87 # Create the TextWrapper object once. | 84 # Create the TextWrapper object once. |
| 88 self._text_wrapper = TextWrapper( | 85 self._text_wrapper = TextWrapper( |
| 89 initial_indent = ' // ', | 86 initial_indent = ' // ', |
| 90 subsequent_indent = ' // ', | 87 subsequent_indent = ' // ', |
| 91 break_long_words = False, | 88 break_long_words = False, |
| 92 width = 80) | 89 width = 80) |
| 93 | 90 |
| 94 def GetTemplateText(self): | 91 def GetTemplateText(self): |
| 95 return '\n'.join(self._out) | 92 return '\n'.join(self._out) |
| OLD | NEW |