Chromium Code Reviews| Index: grit/format/policy_templates/writers/json_writer.py |
| diff --git a/grit/format/policy_templates/writers/json_writer.py b/grit/format/policy_templates/writers/json_writer.py |
| index 4739483b10d264deac8cb68a260b6ab10ec92266..673bbf7deec77f8a2e8a26bc658a2bd47ce15ebe 100644 |
| --- a/grit/format/policy_templates/writers/json_writer.py |
| +++ b/grit/format/policy_templates/writers/json_writer.py |
| @@ -3,6 +3,8 @@ |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| +import json |
|
pastarmovj
2014/04/07 09:49:44
Not 100% sure but wasn't there some issue or incom
Joao da Silva
2014/04/07 10:10:48
Yes, that was fixed by https://codereview.chromium
|
| + |
| from textwrap import TextWrapper |
| from grit.format.policy_templates.writers import template_writer |
| @@ -38,28 +40,10 @@ class JsonWriter(template_writer.TemplateWriter): |
| return self.FlattenGroupsAndSortPolicies(policy_list) |
| def WritePolicy(self, policy): |
| - example_value = policy['example_value'] |
| - if policy['type'] == 'string': |
| - example_value_str = '"' + example_value + '"' |
| - elif policy['type'] in ('int', 'int-enum', 'dict'): |
| - example_value_str = str(example_value) |
| - elif policy['type'] == 'list': |
| - if example_value == []: |
| - example_value_str = '[]' |
| - else: |
| - example_value_str = '["%s"]' % '", "'.join(example_value) |
| - elif policy['type'] == 'main': |
| - if example_value == True: |
| - example_value_str = 'true' |
| - else: |
| - example_value_str = 'false' |
| - elif policy['type'] == 'string-enum': |
| - example_value_str = '"%s"' % example_value; |
| - elif policy['type'] == 'external': |
| + if policy['type'] == 'external': |
| # This type can only be set through cloud policy. |
| return |
| - else: |
| - raise Exception('unknown policy type %s:' % policy['type']) |
| + example_value_str = json.dumps(policy['example_value'], sort_keys=True) |
| # Add comma to the end of the previous line. |
| if not self._first_written: |