Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(262)

Unified Diff: grit/format/policy_templates/writers/json_writer.py

Issue 227073006: Added a policy writer for iOS Plists. (Closed) Base URL: https://chromium.googlesource.com/external/grit-i18n.git@master
Patch Set: rebase Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: grit/format/policy_templates/writers/json_writer.py
===================================================================
--- grit/format/policy_templates/writers/json_writer.py (revision 158)
+++ grit/format/policy_templates/writers/json_writer.py (working copy)
@@ -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
+
from textwrap import TextWrapper
from grit.format.policy_templates.writers import template_writer
@@ -38,28 +40,10 @@
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:
« no previous file with comments | « grit/format/policy_templates/writers/doc_writer.py ('k') | grit/format/policy_templates/writers/json_writer_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698