| OLD | NEW |
| 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 Loading... |
| 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 CanBeMandatory(self, policy): |
| 91 '''Checks if the given policy can be mandatory.''' |
| 92 return policy.get('features', {}).get('can_be_mandatory', True) |
| 93 |
| 90 def IsPolicySupportedOnPlatform(self, policy, platform): | 94 def IsPolicySupportedOnPlatform(self, policy, platform): |
| 91 '''Checks if |policy| is supported on |platform|. | 95 '''Checks if |policy| is supported on |platform|. |
| 92 | 96 |
| 93 Args: | 97 Args: |
| 94 policy: The dictionary of the policy. | 98 policy: The dictionary of the policy. |
| 95 platform: The platform to check; one of 'win', 'mac', 'linux' or | 99 platform: The platform to check; one of 'win', 'mac', 'linux' or |
| 96 'chrome_os'. | 100 'chrome_os'. |
| 97 ''' | 101 ''' |
| 98 is_supported = lambda x: platform in x['platforms'] | 102 is_supported = lambda x: platform in x['platforms'] |
| 99 return any(filter(is_supported, policy['supported_on'])) | 103 return any(filter(is_supported, policy['supported_on'])) |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 ''' | 293 ''' |
| 290 is_group = policy['type'] == 'group' | 294 is_group = policy['type'] == 'group' |
| 291 if is_group: | 295 if is_group: |
| 292 # Groups are sorted by caption. | 296 # Groups are sorted by caption. |
| 293 str_key = policy['caption'] | 297 str_key = policy['caption'] |
| 294 else: | 298 else: |
| 295 # Regular policies are sorted by name. | 299 # Regular policies are sorted by name. |
| 296 str_key = policy['name'] | 300 str_key = policy['name'] |
| 297 # Groups come before regular policies. | 301 # Groups come before regular policies. |
| 298 return (not is_group, str_key) | 302 return (not is_group, str_key) |
| OLD | NEW |