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

Side by Side Diff: components/policy/tools/template_writers/writers/json_writer.py

Issue 2653823006: Include 'external' policies in grit output (admx, adm, doc etc.) (Closed)
Patch Set: Whitespace fix Created 3 years, 3 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 unified diff | Download patch
OLDNEW
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
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
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)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698