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

Side by Side Diff: tools/grit/grit/format/policy_templates/writers/template_writer.py

Issue 4164006: Generate example JSON policy configuration files (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: " Created 10 years, 1 month 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 | Annotate | Revision Log
OLDNEW
1 # Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 5
6 class TemplateWriter(object): 6 class TemplateWriter(object):
7 '''Abstract base class for writing policy templates in various formats. 7 '''Abstract base class for writing policy templates in various formats.
8 The methods of this class will be called by PolicyTemplateGenerator. 8 The methods of this class will be called by PolicyTemplateGenerator.
9 ''' 9 '''
10 10
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 for policy in template: 83 for policy in template:
84 if policy['type'] == 'group': 84 if policy['type'] == 'group':
85 child_policies = self._GetPoliciesForWriter(policy) 85 child_policies = self._GetPoliciesForWriter(policy)
86 if child_policies: 86 if child_policies:
87 # Only write nonempty groups. 87 # Only write nonempty groups.
88 self.BeginPolicyGroup(policy) 88 self.BeginPolicyGroup(policy)
89 for child_policy in child_policies: 89 for child_policy in child_policies:
90 # Nesting of groups is currently not supported. 90 # Nesting of groups is currently not supported.
91 self.WritePolicy(child_policy) 91 self.WritePolicy(child_policy)
92 self.EndPolicyGroup() 92 self.EndPolicyGroup()
93 else: 93 elif self.IsPolicySupported(policy):
94 self.WritePolicy(policy) 94 self.WritePolicy(policy)
95 self.EndTemplate() 95 self.EndTemplate()
96 return self.GetTemplateText() 96 return self.GetTemplateText()
97 97
98 def WritePolicy(self, policy): 98 def WritePolicy(self, policy):
99 '''Appends the template text corresponding to a policy into the 99 '''Appends the template text corresponding to a policy into the
100 internal buffer. 100 internal buffer.
101 101
102 Args: 102 Args:
103 policy: The policy as it is found in the JSON file. 103 policy: The policy as it is found in the JSON file.
(...skipping 27 matching lines...) Expand all
131 ''' 131 '''
132 pass 132 pass
133 133
134 def GetTemplateText(self): 134 def GetTemplateText(self):
135 '''Gets the content of the internal template buffer. 135 '''Gets the content of the internal template buffer.
136 136
137 Returns: 137 Returns:
138 The generated template from the the internal buffer as a string. 138 The generated template from the the internal buffer as a string.
139 ''' 139 '''
140 raise NotImplementedError() 140 raise NotImplementedError()
OLDNEW
« no previous file with comments | « tools/grit/grit/format/policy_templates/writers/json_writer_unittest.py ('k') | tools/grit/grit/node/misc.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698