Lines Matching refs:policy

8   '''Abstract base class for writing policy templates in various formats.
24 are also present in the policy data structures that are passed to
28 cannot be associated with any policy or group.
33 def IsDeprecatedPolicySupported(self, policy):
34 '''Checks if the given deprecated policy is supported by the writer.
37 policy: The dictionary of the policy.
40 True if the writer chooses to include the deprecated 'policy' in its
45 def IsFuturePolicySupported(self, policy):
46 '''Checks if the given future policy is supported by the writer.
49 policy: The dictionary of the policy.
52 True if the writer chooses to include the deprecated 'policy' in its
57 def IsPolicySupported(self, policy):
58 '''Checks if the given policy is supported by the writer.
61 the policy.
64 policy: The dictionary of the policy.
67 True if the writer chooses to include 'policy' in its output.
69 if ('deprecated' in policy and policy['deprecated'] is True and
70 not self.IsDeprecatedPolicySupported(policy)):
73 if ('future' in policy and policy['future'] is True and
74 not self.IsFuturePolicySupported(policy)):
80 for supported_on in policy['supported_on']:
86 def CanBeRecommended(self, policy):
87 '''Checks if the given policy can be recommended.'''
88 return policy.get('features', {}).get('can_be_recommended', False)
90 def CanBeMandatory(self, policy):
91 '''Checks if the given policy can be mandatory.'''
92 return policy.get('features', {}).get('can_be_mandatory', True)
94 def IsPolicySupportedOnPlatform(self, policy, platform):
95 '''Checks if |policy| is supported on |platform|.
98 policy: The dictionary of the policy.
103 return any(filter(is_supported, policy['supported_on']))
110 group: The dictionary of the policy group.
112 Returns: The list of policies of the policy group that are compatible
118 for policy in group['policies']:
119 if self.IsPolicySupported(policy):
120 result.append(policy)
144 for policy in template['policy_definitions']:
145 if policy['type'] == 'group':
146 child_policies = self._GetPoliciesForWriter(policy)
151 self.BeginPolicyGroup(policy)
157 self.BeginRecommendedPolicyGroup(policy)
161 elif self.IsPolicySupported(policy):
162 self.WritePolicy(policy)
163 if self.CanBeRecommended(policy):
164 self.WriteRecommendedPolicy(policy)
181 The sorted policy list.
185 def WritePolicy(self, policy):
186 '''Appends the template text corresponding to a policy into the
190 policy: The policy as it is found in the JSON file.
194 def WriteRecommendedPolicy(self, policy):
195 '''Appends the template text corresponding to a recommended policy into the
199 policy: The recommended policy as it is found in the JSON file.
207 policy group into the internal buffer.
210 group: The policy group as it is found in the JSON file.
216 policy group into the internal buffer.
222 policy group into the internal buffer.
225 group: The recommended policy group as it is found in the JSON file.
231 policy group into the internal buffer.
275 for policy in policy_list:
276 if policy['type'] == 'group':
277 for grouped_policy in policy['policies']:
280 new_list.append(policy)
286 def GetPolicySortingKeyName(self, policy):
287 return policy['name']
289 def GetPolicySortingKeyGroupsFirst(self, policy):
290 '''Extracts a sorting key from a policy. These keys can be used for
294 is_group = policy['type'] == 'group'
297 str_key = policy['caption']
300 str_key = policy['name']