components/policy/tools/template_writers/policy_template_generator.py
def _ExpandGroups(self, policy_list):
    '''Replaces policies names inside group definitions for actual policies
    definitions. If policy does not belong to any group, leave it as is.

    Args:
      policy_list: A list of policies and groups.

    Returns:
      Modified policy_list
    '''
    groups = [policy for policy in policy_list if IsGroupOrAtomicGroup(policy)]
    policies = {
        policy['name']: policy
        for policy in policy_list
        if not IsGroupOrAtomicGroup(policy)
    }
    policies_in_groups = set()
    result_policies = []
    for group in groups:
      group_policies = group['policies']
      expanded_policies = [
          policies[policy_name] for policy_name in group_policies
      ]
      assert policies_in_groups.isdisjoint(group_policies)
      policies_in_groups.update(group_policies)
      group['policies'] = expanded_policies
      result_policies.append(group)

    result_policies.extend([
        policy for policy in policy_list if not IsGroupOrAtomicGroup(policy) and
        policy['name'] not in policies_in_groups
    ])
    return result_policies
Replaces policies names inside group definitions for actual policies
    definitions. If policy does not belong to any group, leave it as is.

    Args:
      policy_list: A list of policies and groups.

    Returns:
      Modified policy_list
    
Replaces policies names inside group definitions for actual policies
definitions. If policy does not belong to any group, leave it as is.
Replaces policies names inside group definitions for actual policies definitions . If policy does not belong to any group leave it as is .
def _ExpandGroups(self, policy_list):
    groups = [policy for policy in policy_list if IsGroupOrAtomicGroup(policy)]
    policies = {
        policy['name']: policy
        for policy in policy_list
        if not IsGroupOrAtomicGroup(policy)
    }
    policies_in_groups = set()
    result_policies = []
    for group in groups:
      group_policies = group['policies']
      expanded_policies = [
          policies[policy_name] for policy_name in group_policies
      ]
      assert policies_in_groups.isdisjoint(group_policies)
      policies_in_groups.update(group_policies)
      group['policies'] = expanded_policies
      result_policies.append(group)
    result_policies.extend([
        policy for policy in policy_list if not IsGroupOrAtomicGroup(policy) and
        policy['name'] not in policies_in_groups
    ])
    return result_policies
def _ExpandGroups ( self , policy_list ) : groups = [ policy for policy in policy_list if IsGroupOrAtomicGroup ( policy ) ] policies = { policy [ 'name' ] : policy for policy in policy_list if not IsGroupOrAtomicGroup ( policy ) } policies_in_groups = set ( ) result_policies = [ ] for group in groups : group_policies = group [ 'policies' ] expanded_policies = [ policies [ policy_name ] for policy_name in group_policies ] assert policies_in_groups . isdisjoint ( group_policies ) policies_in_groups . update ( group_policies ) group [ 'policies' ] = expanded_policies result_policies . append ( group ) result_policies . extend ( [ policy for policy in policy_list if not IsGroupOrAtomicGroup ( policy ) and policy [ 'name' ] not in policies_in_groups ] ) return result_policies
Replaces policies names inside group definitions for actual policies
definitions.
Replaces policies names inside group definitions for actual policies definitions .
'''Replaces policies names inside group definitions for actual policies
    definitions. If policy does not belong to any group, leave it as is.

    Args:
      policy_list: A list of policies and groups.

    Returns:
      Modified policy_list
    '''
None
self
policy_list
A list of policies and groups.
A list of policies and groups .