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

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
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 os
6 7
7 class TemplateWriter(object): 8 class TemplateWriter(object):
8 '''Abstract base class for writing policy templates in various formats. 9 '''Abstract base class for writing policy templates in various formats.
9 The methods of this class will be called by PolicyTemplateGenerator. 10 The methods of this class will be called by PolicyTemplateGenerator.
10 ''' 11 '''
11 12
12 def __init__(self, platforms, config): 13 def __init__(self, platforms, config):
13 '''Initializes a TemplateWriter object. 14 '''Initializes a TemplateWriter object.
14 15
15 Args: 16 Args:
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 '''Checks if |policy| is supported on |platform|. 96 '''Checks if |policy| is supported on |platform|.
96 97
97 Args: 98 Args:
98 policy: The dictionary of the policy. 99 policy: The dictionary of the policy.
99 platform: The platform to check; one of 'win', 'mac', 'linux' or 100 platform: The platform to check; one of 'win', 'mac', 'linux' or
100 'chrome_os'. 101 'chrome_os'.
101 ''' 102 '''
102 is_supported = lambda x: platform in x['platforms'] 103 is_supported = lambda x: platform in x['platforms']
103 return any(filter(is_supported, policy['supported_on'])) 104 return any(filter(is_supported, policy['supported_on']))
104 105
106 def _GetChromiumVersionString(self):
107 '''Returns the Chromium version string stored in the environment variable
108 version (if it is set).
109
110 Returns: The Chromium version string or an empty string if it has not been s et.
pastarmovj 2014/10/07 14:54:36 too long.
cschuet1 2014/10/07 15:42:47 Done.
111 '''
112 if('version' in self.config):
pastarmovj 2014/10/07 14:54:36 space after if, no braces.
cschuet1 2014/10/07 15:42:47 Done.
113 return self.config['version']
114
105 def _GetPoliciesForWriter(self, group): 115 def _GetPoliciesForWriter(self, group):
106 '''Filters the list of policies in the passed group that are supported by 116 '''Filters the list of policies in the passed group that are supported by
107 the writer. 117 the writer.
108 118
109 Args: 119 Args:
110 group: The dictionary of the policy group. 120 group: The dictionary of the policy group.
111 121
112 Returns: The list of policies of the policy group that are compatible 122 Returns: The list of policies of the policy group that are compatible
113 with the writer. 123 with the writer.
114 ''' 124 '''
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 194
185 def WritePolicy(self, policy): 195 def WritePolicy(self, policy):
186 '''Appends the template text corresponding to a policy into the 196 '''Appends the template text corresponding to a policy into the
187 internal buffer. 197 internal buffer.
188 198
189 Args: 199 Args:
190 policy: The policy as it is found in the JSON file. 200 policy: The policy as it is found in the JSON file.
191 ''' 201 '''
192 raise NotImplementedError() 202 raise NotImplementedError()
193 203
204 def WriteComment(self, comment):
205 '''Appends the comment to the internal buffer.
pastarmovj 2014/10/07 14:54:36 something is fishy with those lines - too many whi
cschuet1 2014/10/07 15:42:47 Done.
206 Args:
207 comment: The comment to be added.
208 '''
209 raise NotImplementedError()
210
194 def WriteRecommendedPolicy(self, policy): 211 def WriteRecommendedPolicy(self, policy):
195 '''Appends the template text corresponding to a recommended policy into the 212 '''Appends the template text corresponding to a recommended policy into the
196 internal buffer. 213 internal buffer.
197 214
198 Args: 215 Args:
199 policy: The recommended policy as it is found in the JSON file. 216 policy: The recommended policy as it is found in the JSON file.
200 ''' 217 '''
201 # TODO 218 # TODO
202 #raise NotImplementedError() 219 #raise NotImplementedError()
203 pass 220 pass
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 ''' 310 '''
294 is_group = policy['type'] == 'group' 311 is_group = policy['type'] == 'group'
295 if is_group: 312 if is_group:
296 # Groups are sorted by caption. 313 # Groups are sorted by caption.
297 str_key = policy['caption'] 314 str_key = policy['caption']
298 else: 315 else:
299 # Regular policies are sorted by name. 316 # Regular policies are sorted by name.
300 str_key = policy['name'] 317 str_key = policy['name']
301 # Groups come before regular policies. 318 # Groups come before regular policies.
302 return (not is_group, str_key) 319 return (not is_group, str_key)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698