Walk the AST applying the policy
500129
function apply(x) {
      const policyPathLength = policyPath.length;
      policyPath[policyPathLength] = x;
      if (Array.isArray(x)) {
        for (let i = 0, len = x.length; i < len; ++i) {
          policyPath[policyPathLength + 1] = i;
          apply(x[i]);
        }
      } else if (x && typeof x === 'object') {
        for (const key of Object.getOwnPropertyNames(x)) {
          policyPath[policyPathLength + 1] = key;
          const valueType = typeof policy[key];
          if (valueType === 'function') {
            policy[key](x[key]);
          } else if (valueType === 'object') {
            const policyMember = policy[key][x[key]];
            if (typeof policyMember === 'function') {
              policyMember(x);
            }
          }
          if (key === 'test' || key === 'expr') {
            checkCodeDoesNotInterfere(x, key, true);
          }
          apply(x[key]);
        }
      }
      policyPath.length = policyPathLength;
    }
292232
def policy(name, options = {}, &block)
      p = Sprinkle::Policy.new(name, options, &block)
      POLICIES << p
      p
    end
527218
def _link_policy(self, role):
        
        policy_arn = self.get_policy_arn()
        if role is not None and policy_arn not in role.ManagedPolicyArns:
            role.ManagedPolicyArns.append(policy_arn)
948167
function(obj, visitor, context, traversalStrategy) {
      traversalStrategy = traversalStrategy || this._traversalStrategy;
      walkImpl(obj, traversalStrategy, null, visitor, context);
    }
204931
function steppingDispatch() {
        applyExternalEffect(options.stepping.effect);  // WARNING: may change `options.stepping.effect`
        var event = options.dequeue(events);
        if (!event) {
            return false;
        }
        var effect = options.stepping.effect;
        effect.event = event;
        try {
            var behavior = event.context.behavior;
            effect.behavior = behavior;
            event.context.behavior(event.message);  // execute actor behavior
            if (behavior !== event.context.behavior) {
                effect.became = event.context.behavior;
            }
        } catch (exception) {
            effect.exception = exception;
        }
        applyBehaviorEffect(effect);  // WARNING: will change `options.stepping.effect`
        return effect;
    }
136702
def _apply_policy_config(policy_spec, policy_dict):
    ''''''
    log.trace('policy_dict = %s', policy_dict)
    if policy_dict.get('name'):
        policy_spec.name = policy_dict['name']
    if policy_dict.get('description'):
        policy_spec.description = policy_dict['description']
    if policy_dict.get('subprofiles'):
        # Incremental changes to subprofiles and capabilities are not
        # supported because they would complicate updates too much
        # The whole configuration of all sub-profiles is expected and applied
        policy_spec.constraints = pbm.profile.SubProfileCapabilityConstraints()
        subprofiles = []
        for subprofile_dict in policy_dict['subprofiles']:
            subprofile_spec = \
                    pbm.profile.SubProfileCapabilityConstraints.SubProfile(
                        name=subprofile_dict['name'])
            cap_specs = []
            if subprofile_dict.get('force_provision'):
                subprofile_spec.forceProvision = \
                        subprofile_dict['force_provision']
            for cap_dict in subprofile_dict['capabilities']:
                prop_inst_spec = pbm.capability.PropertyInstance(
                    id=cap_dict['id']
                )
                setting_type = cap_dict['setting']['type']
                if setting_type == 'set':
                    prop_inst_spec.value = pbm.capability.types.DiscreteSet()
                    prop_inst_spec.value.values = cap_dict['setting']['values']
                elif setting_type == 'range':
                    prop_inst_spec.value = pbm.capability.types.Range()
                    prop_inst_spec.value.max = cap_dict['setting']['max']
                    prop_inst_spec.value.min = cap_dict['setting']['min']
                elif setting_type == 'scalar':
                    prop_inst_spec.value = cap_dict['setting']['value']
                cap_spec = pbm.capability.CapabilityInstance(
                    id=pbm.capability.CapabilityMetadata.UniqueId(
                        id=cap_dict['id'],
                        namespace=cap_dict['namespace']),
                    constraint=[pbm.capability.ConstraintInstance(
                        propertyInstance=[prop_inst_spec])])
                cap_specs.append(cap_spec)
            subprofile_spec.capability = cap_specs
            subprofiles.append(subprofile_spec)
        policy_spec.constraints.subProfiles = subprofiles
    log.trace('updated policy_spec = %s', policy_spec)
    return policy_spec
127745
function walk(arr, key, fn) {
        var l = arr.length,
            children;

        while (l--) {
            children = arr[l][key];

            if (children) {
                walk(children, key, fn);
            }
            fn(arr[l]);
        }
    }
595893
public function registerPolicies()
    {
        foreach ($this->policies as $key => $value) {
            IlluminateGate::policy($key, $value);
        }
    }
896458
protected function performStep()
    {
        $activeColumn = $this->getActivateColumnName();

        foreach ($this->info->attributes as $name => $attribute) {

            if ($name !== $activeColumn || ! $this->isAttributeBoolean($attribute)) {
                continue;
            }

            $this->info->list->activatable   = true;
            $this->info->list->active_column = $name;
        }
    }
1243509
def verify_policy(opts)
      result = policy.constantize.call(opts)
    rescue NameError
      result = true
    ensure
      return result
    end
843962
def policy(self, args):
        

        word = args[0]
        if word == 'reject':
            self.accepted_ports = None
            self.rejected_ports = []
            target = self.rejected_ports

        elif word == 'accept':
            self.accepted_ports = []
            self.rejected_ports = None
            target = self.accepted_ports

        else:
            raise RuntimeError("Don't understand policy word \"%s\"" % word)

        for port in args[1].split(','):
            if '-' in port:
                (a, b) = port.split('-')
                target.append(PortRange(int(a), int(b)))
            else:
                target.append(int(port))
396543
def _calculatePolicy(self):
        """"""
        cmd = '''
              UPDATE policy
                 SET action = (
                     SELECT action
                       FROM (SELECT state, action, MAX(value)
                               FROM Q
                              GROUP BY state) AS A
                       WHERE policy.state = A.state
                       GROUP BY state);'''
        self._cur.execute(cmd)
        self._conn.commit()
407905
def update_rbac_policy(self, rbac_policy_id, body=None):
        """"""
        return self.put(self.rbac_policy_path % rbac_policy_id, body=body)
992059
def apply_policy(self, policy):
        
        tenant_name = policy['tenant_name']
        fw_id = policy['fw_id']
        fw_name = policy['fw_name']
        LOG.info("asa_apply_policy: tenant=%(tenant)s fw_id=%(fw_id)s "
                 "fw_name=%(fw_name)s",
                 {'tenant': tenant_name, 'fw_id': fw_id, 'fw_name': fw_name})
        cmds = ["conf t", "changeto context " + tenant_name]

        for rule_id, rule in policy['rules'].items():
            acl = self.build_acl(tenant_name, rule)

            LOG.info("rule[%(rule_id)s]: name=%(name)s enabled=%(enabled)s"
                     " protocol=%(protocol)s dport=%(dport)s "
                     "sport=%(sport)s dip=%(dport)s "
                     "sip=%(sip)s action=%(dip)s",
                     {'rule_id': rule_id, 'name': rule.get('name'),
                      'enabled': rule.get('enabled'),
                      'protocol': rule.get('protocol'),
                      'dport': rule.get('dst_port'),
                      'sport': rule.get('src_port'),
                      'dip': rule.get('destination_ip_address'),
                      'sip': rule.get('source_ip_address'),
                      'action': rule.get('action')})

            # remove the old ace for this rule
            if rule_id in self.rule_tbl:
                cmds.append('no ' + self.rule_tbl[rule_id])

            self.rule_tbl[rule_id] = acl
            if tenant_name in self.tenant_rule:
                if rule_id not in self.tenant_rule[tenant_name]['rule_lst']:
                    self.tenant_rule[tenant_name]['rule_lst'].append(rule_id)
            cmds.append(acl)
        cmds.append("access-group " + tenant_name + " global")
        cmds.append("write memory")

        LOG.info("cmds sent is %s", cmds)
        data = {"commands": cmds}
        return self.rest_send_cli(data)
863647
def add_policy(self, name, policy_type, cooldown, change=None,
            is_percent=False, desired_capacity=None, args=None):
        
        return self.manager.add_policy(self, name, policy_type, cooldown,
                change=change, is_percent=is_percent,
                desired_capacity=desired_capacity, args=args)
759568
def apply(self, func, args=(), kwds=dict()):
        """"""
        return self.apply_async(func, args, kwds).get()
659633
function(walk) {
    return this.tryBracing(walk, '```', '```', function(w) {
      this.out.push("<code>");
      while (w.hasCurrent())
        this.emitPlain(w);
      this.out.push("</code>");
    });
  }