return the named subset of policies
170848
def select(self, names):
        """"""
        return PolicyCollection(
            [p for p in self.policies if p.name in names], self.options)
200239
public List<List<String>> getPolicy(String sec, String ptype) {
        return model.get(sec).get(ptype).policy;
    }
22520
def get_targets(self, name=None):
        
        targets = []
        for section in self.get_sections():
            if section.endswith(u'Target'):
                targets += [value for value in self._sections[section]]

        if name is None:
            return targets

        if not isinstance(name, list):
            name = [name]

        return [target for target in targets if target.name in name]
904301
def get_ordered_with_policy(self, policy, max_ncpus):
        
        # Build new list since we are gonna change the object in place.
        hints = self.__class__(self.info, confs=[c for c in self if c.num_cores <= max_ncpus])

        # First select the configurations satisfying the condition specified by the user (if any)
        bkp_hints = hints.copy()
        if policy.condition:
            logger.info("Applying condition %s" % str(policy.condition))
            hints.select_with_condition(policy.condition)

            # Undo change if no configuration fullfills the requirements.
            if not hints:
                hints = bkp_hints
                logger.warning("Empty list of configurations after policy.condition")

        # Now filter the configurations depending on the values in vars
        bkp_hints = hints.copy()
        if policy.vars_condition:
            logger.info("Applying vars_condition %s" % str(policy.vars_condition))
            hints.select_with_condition(policy.vars_condition, key="vars")

            # Undo change if no configuration fullfills the requirements.
            if not hints:
                hints = bkp_hints
                logger.warning("Empty list of configurations after policy.vars_condition")

        if len(policy.autoparal_priorities) == 1:
            # Example: hints.sort_by_speedup()
            if policy.autoparal_priorities[0] in ['efficiency', 'speedup', 'mem_per_proc']:
                getattr(hints, "sort_by_" + policy.autoparal_priorities[0])()
            elif isinstance(policy.autoparal_priorities[0], collections.Mapping):
                if policy.autoparal_priorities[0]['meta_priority'] == 'highest_speedup_minimum_efficiency_cutoff':
                    min_efficiency = policy.autoparal_priorities[0].get('minimum_efficiency', 1.0)
                    hints.select_with_condition({'efficiency': {'$gte': min_efficiency}})
                    hints.sort_by_speedup()
        else:
            hints = hints.multidimensional_optimization(priorities=policy.autoparal_priorities)
            if len(hints) == 0: raise ValueError("len(hints) == 0")

        #TODO: make sure that num_cores == 1 is never selected when we have more than one configuration
        #if len(hints) > 1:
        #    hints.select_with_condition(dict(num_cores={"$eq": 1)))

        # Return final (orderded ) list of configurations (best first).
        return hints
1307163
def _get_policies(self):
        """"""
        username = self._get_username_for_key()
        policies = self.client.list_user_policies(
            UserName=username
        )
        return policies
382973
def get_terms_in_subset(ont, subset):
    
    namedGraph = get_named_graph(ont)

    # note subsets have an unusual encoding
    query = """
    prefix oboInOwl: <http://www.geneontology.org/formats/oboInOwl#>
    SELECT ?c ? WHERE {{
    GRAPH <{g}>  {{
    ?c oboInOwl:inSubset ?s ;
       rdfs:label ?l
    FILTER regex(?s,'#{s}$','i')
    }}
    }}
    """.format(s=subset, g=namedGraph)
    bindings = run_sparql(query)
    return [(r['c']['value'],r['l']['value']) for r in bindings]
25429
private function getPoliciesNumbers(array $policies): array
    {
        $policiesNumbers = array_column($policies, 'id');

        return array_combine($policiesNumbers, array_fill_keys($policiesNumbers, false));
    }
783911
public static Set<Policy> policies(BasicSettings settings) {
    return settings.policies().stream()
        .flatMap(name -> policy(settings, name).stream())
        .collect(toSet());
  }
473102
def subset(self, names):
        """"""
        vld = VarLookupDict(self._namespaces)
        new_ns = dict((name, vld[name]) for name in names)
        return EvalEnvironment([new_ns], self.flags)
815948
def getControls(self):
        '''
        
        '''
        cLvlNow = np.zeros(self.AgentCount) + np.nan
        MedNow  = np.zeros(self.AgentCount) + np.nan
        for t in range(self.T_cycle):
            these = t == self.t_cycle
            cLvlNow[these], MedNow[these] = self.solution[t].policyFunc(self.mLvlNow[these],self.pLvlNow[these],self.MedShkNow[these])
        self.cLvlNow = cLvlNow
        self.MedNow  = MedNow
        return None
550286
def policies(options = {})
      batches = Enumerator.new do |y|
        options = options.merge(user_name: @name)
        resp = @client.list_user_policies(options)
        resp.each_page do |page|
          batch = []
          page.data.policy_names.each do |p|
            batch << UserPolicy.new(
              user_name: @name,
              name: p,
              client: @client
            )
          end
          y.yield(batch)
        end
      end
      UserPolicy::Collection.new(batches)
    end
307956
def group_for_policy(self, policy=None):
        
        if policy is None:
            policy = self.context.participant_policy
        return "%s:%s" % (policy.title(), self.context.UID())
1203867
def list_lbaas_l7policies(self, retrieve_all=True, **_params):
        """"""
        return self.list('l7policies', self.lbaas_l7policies_path,
                         retrieve_all, **_params)
648407
function getPolicyByName(name, listParams, marker) {
  const iam = new AWS.IAM();
  const params = _.merge({
    Marker: marker,
    MaxItems: 100,
    PathPrefix: '/',
    OnlyAttached: false,
    Scope: 'All'
  }, listParams);
  return iam.listPolicies(params).promise()
  .then(policyList => {
    const policyFound = _.find(policyList.Policies, function(policy) { return policy.PolicyName === name; });
    if (policyFound) {
      return Promise.resolve(policyFound);
    } else if (policyList.IsTruncated) {
      return getPolicyByName(name, listParams, policyList.Marker);
    } else {
      return Promise.resolve(null);
    }
  });
}
571537
def get_all_user_policies(user_name, marker=None, max_items=None, region=None, key=None, keyid=None, profile=None):
    '''
    
    '''
    conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile)
    try:
        info = conn.get_all_user_policies(user_name, marker, max_items)
        if not info:
            return False
        _list = info.list_user_policies_response.list_user_policies_result
        return _list.policy_names
    except boto.exception.BotoServerError as e:
        log.debug(e)
        log.error('Failed to get policies for user %s.', user_name)
        return False
1243509
def verify_policy(opts)
      result = policy.constantize.call(opts)
    rescue NameError
      result = true
    ensure
      return result
    end
1099983
def _get_policies(minion_id, config):
    '''
    
    '''
    _, grains, _ = salt.utils.minions.get_minion_data(minion_id, __opts__)
    policy_patterns = config.get(
                                 'policies',
                                 ['saltstack/minion/{minion}', 'saltstack/minions']
                                )
    mappings = {'minion': minion_id, 'grains': grains or {}}

    policies = []
    for pattern in policy_patterns:
        try:
            for expanded_pattern in _expand_pattern_lists(pattern, **mappings):
                policies.append(
                                expanded_pattern.format(**mappings)
                                                .lower()  # Vault requirement
                               )
        except KeyError:
            log.warning('Could not resolve policy pattern %s', pattern)

    log.debug('%s policies: %s', minion_id, policies)
    return policies