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

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

Issue 631223003: Include chromium version number in policy templates (Closed) Base URL: http://grit-i18n.googlecode.com/svn/trunk/
Patch Set: Created 6 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « grit/format/policy_templates/writers/reg_writer_unittest.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 6
7 class TemplateWriter(object): 7 class TemplateWriter(object):
8 '''Abstract base class for writing policy templates in various formats. 8 '''Abstract base class for writing policy templates in various formats.
9 The methods of this class will be called by PolicyTemplateGenerator. 9 The methods of this class will be called by PolicyTemplateGenerator.
10 ''' 10 '''
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 '''Checks if |policy| is supported on |platform|. 95 '''Checks if |policy| is supported on |platform|.
96 96
97 Args: 97 Args:
98 policy: The dictionary of the policy. 98 policy: The dictionary of the policy.
99 platform: The platform to check; one of 'win', 'mac', 'linux' or 99 platform: The platform to check; one of 'win', 'mac', 'linux' or
100 'chrome_os'. 100 'chrome_os'.
101 ''' 101 '''
102 is_supported = lambda x: platform in x['platforms'] 102 is_supported = lambda x: platform in x['platforms']
103 return any(filter(is_supported, policy['supported_on'])) 103 return any(filter(is_supported, policy['supported_on']))
104 104
105 def _GetChromiumVersionString(self):
106 '''Returns the Chromium version string stored in the environment variable
107 version (if it is set).
108
109 Returns: The Chromium version string or None if it has not been set.'''
110
111 if 'version' in self.config:
112 return self.config['version']
113
105 def _GetPoliciesForWriter(self, group): 114 def _GetPoliciesForWriter(self, group):
106 '''Filters the list of policies in the passed group that are supported by 115 '''Filters the list of policies in the passed group that are supported by
107 the writer. 116 the writer.
108 117
109 Args: 118 Args:
110 group: The dictionary of the policy group. 119 group: The dictionary of the policy group.
111 120
112 Returns: The list of policies of the policy group that are compatible 121 Returns: The list of policies of the policy group that are compatible
113 with the writer. 122 with the writer.
114 ''' 123 '''
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 193
185 def WritePolicy(self, policy): 194 def WritePolicy(self, policy):
186 '''Appends the template text corresponding to a policy into the 195 '''Appends the template text corresponding to a policy into the
187 internal buffer. 196 internal buffer.
188 197
189 Args: 198 Args:
190 policy: The policy as it is found in the JSON file. 199 policy: The policy as it is found in the JSON file.
191 ''' 200 '''
192 raise NotImplementedError() 201 raise NotImplementedError()
193 202
203 def WriteComment(self, comment):
204 '''Appends the comment to the internal buffer.
205
206 comment: The comment to be added.
207 '''
208 raise NotImplementedError()
209
194 def WriteRecommendedPolicy(self, policy): 210 def WriteRecommendedPolicy(self, policy):
195 '''Appends the template text corresponding to a recommended policy into the 211 '''Appends the template text corresponding to a recommended policy into the
196 internal buffer. 212 internal buffer.
197 213
198 Args: 214 Args:
199 policy: The recommended policy as it is found in the JSON file. 215 policy: The recommended policy as it is found in the JSON file.
200 ''' 216 '''
201 # TODO 217 # TODO
202 #raise NotImplementedError() 218 #raise NotImplementedError()
203 pass 219 pass
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 ''' 309 '''
294 is_group = policy['type'] == 'group' 310 is_group = policy['type'] == 'group'
295 if is_group: 311 if is_group:
296 # Groups are sorted by caption. 312 # Groups are sorted by caption.
297 str_key = policy['caption'] 313 str_key = policy['caption']
298 else: 314 else:
299 # Regular policies are sorted by name. 315 # Regular policies are sorted by name.
300 str_key = policy['name'] 316 str_key = policy['name']
301 # Groups come before regular policies. 317 # Groups come before regular policies.
302 return (not is_group, str_key) 318 return (not is_group, str_key)
OLDNEW
« no previous file with comments | « grit/format/policy_templates/writers/reg_writer_unittest.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698