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

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

Issue 91273002: Improve platform support indications for policy documentation. (Closed) Base URL: https://chromium.googlesource.com/external/grit-i18n.git@master
Patch Set: Created 7 years 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 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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 for supported_on in policy['supported_on']: 80 for supported_on in policy['supported_on']:
81 for supported_on_platform in supported_on['platforms']: 81 for supported_on_platform in supported_on['platforms']:
82 if supported_on_platform in self.platforms: 82 if supported_on_platform in self.platforms:
83 return True 83 return True
84 return False 84 return False
85 85
86 def CanBeRecommended(self, policy): 86 def CanBeRecommended(self, policy):
87 '''Checks if the given policy can be recommended.''' 87 '''Checks if the given policy can be recommended.'''
88 return policy.get('features', {}).get('can_be_recommended', False) 88 return policy.get('features', {}).get('can_be_recommended', False)
89 89
90 def IsPolicySupportedOnPlatform(self, policy, platform):
91 '''Checks if |policy| is supported on |platform|.
92
93 Args:
94 policy: The dictionary of the policy.
95 platform: The platform to check; one of 'win', 'mac', 'linux' or
96 'chrome_os'.
97 '''
98 is_supported = lambda x: platform in x['platforms']
99 return any(filter(is_supported, policy['supported_on']))
100
90 def _GetPoliciesForWriter(self, group): 101 def _GetPoliciesForWriter(self, group):
91 '''Filters the list of policies in the passed group that are supported by 102 '''Filters the list of policies in the passed group that are supported by
92 the writer. 103 the writer.
93 104
94 Args: 105 Args:
95 group: The dictionary of the policy group. 106 group: The dictionary of the policy group.
96 107
97 Returns: The list of policies of the policy group that are compatible 108 Returns: The list of policies of the policy group that are compatible
98 with the writer. 109 with the writer.
99 ''' 110 '''
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 ''' 289 '''
279 is_group = policy['type'] == 'group' 290 is_group = policy['type'] == 'group'
280 if is_group: 291 if is_group:
281 # Groups are sorted by caption. 292 # Groups are sorted by caption.
282 str_key = policy['caption'] 293 str_key = policy['caption']
283 else: 294 else:
284 # Regular policies are sorted by name. 295 # Regular policies are sorted by name.
285 str_key = policy['name'] 296 str_key = policy['name']
286 # Groups come before regular policies. 297 # Groups come before regular policies.
287 return (not is_group, str_key) 298 return (not is_group, str_key)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698