Parse a single base check rule into an appropriate Check object.
194276
def _parse_check(self, rule):
        """"""

        # Handle the special constant-type checks
        for check_cls in (checks.FalseCheck, checks.TrueCheck):
            check = check_cls()
            if rule == str(check):
                return check

        try:
            kind, match = rule.split(':', 1)
        except Exception:
            if self.raise_error:
                raise InvalidRuleException(rule)
            else:
                LOG.exception('Failed to understand rule %r', rule)
                # If the rule is invalid, we'll fail closed
                return checks.FalseCheck()

        if kind in checks.registered_checks:
            return checks.registered_checks[kind](kind, match)
        elif None in checks.registered_checks:
            return checks.registered_checks[None](kind, match)
        elif self.raise_error:
            raise InvalidRuleException(rule)
        else:
            LOG.error('No handler for matches of kind %r', kind)
            # If the rule is invalid, we'll fail closed
            return checks.FalseCheck()
246296
def parse_rule(input = @tokens)
      input = TokenScanner.new(input) unless input.is_a?(TokenScanner)

      while input.peek && input.peek[:node] == :whitespace
        input.consume
      end

      if input.peek.nil?
        # Syntax error.
        return create_node(:error, :value => 'empty')
      elsif input.peek[:node] == :at_keyword
        rule = consume_at_rule(input)
      else
        rule = consume_qualified_rule(input)
      end

      while input.peek && input.peek[:node] == :whitespace
        input.consume
      end

      if input.peek.nil?
        rule
      else
        # Syntax error.
        create_node(:error, :value => 'extra-input')
      end
    end
914946
def _parse_bool(value):
    """"""
    if isinstance(value, bool):
        return value

    elif isinstance(value, str):
        if value == 'True':
            return True
        elif value == 'False':
            return False

    raise Exception("Value %s is not boolean." % value)
926260
function filterValidRule(rule) {
  return (rule.hasOwnProperty('match')&&typeof rule.match === "object")
  && (rule.hasOwnProperty('use') && (
    typeof rule.use === "object"
    || typeof rule.use === "function"
  ))
  && (
    (rule.match.hasOwnProperty('request'))
    || (rule.match.hasOwnProperty('base'))
  )
}
1222134
def process_rule(self,rule,pa,tuple):
        ''' 
        '''
        for i,v in enumerate(tuple):
            rule = rule.replace(pa[i],str(v))
        return eval(rule)
1003847
function parse (input, opts) {
  // Wrap parser.parse to allow specifying the start rule
  // as a shorthand option
  if (!opts) {
    opts = {}
  }
  else if (typeof opts == 'string') {
    opts = { startRule: opts }
  }
  return parser.parse(input, opts)
}
1055205
function getRule(commitlintConfig, ruleName) {
	const rule = commitlintConfig.rules[ruleName];

	if (rule) {
		return {
			raw: rule,
			level: rule[0],
			applicable: rule[1],
			value: rule[2],
		};
	}
}
818484
function standardizeRule( rule ) {
		rule.elements = convertValidatorToHash( rule.elements, /\s+/ ) || null;
		rule.propertiesOnly = rule.propertiesOnly || ( rule.elements === true );

		var delim = /\s*,\s*/,
			i;

		for ( i in validators ) {
			rule[ i ] = convertValidatorToHash( rule[ i ], delim ) || null;
			rule[ validatorsRequired[ i ] ] = extractRequired( convertValidatorToHash(
				rule[ validatorsRequired[ i ] ], delim ), rule[ i ] ) || null;
		}

		rule.match = rule.match || null;
	}
221209
function parse_rule() {
		$rule = trim( $this->rule ) ;

		/* If this is a regex end-token, just mark it and return */
		if ( substr( $rule, 0, 1 ) == '/' ) {
			$this->parsed = new TokenRegex( $rule ) ;
		}
		else {
			$tokens = array() ;
			$this->tokenize( $rule, $tokens ) ;
			$this->parsed = ( count( $tokens ) == 1 ? array_pop( $tokens ) : new TokenSequence( $tokens ) ) ;
		}
		
	}
776908
def _check_pointers(parser):
    """"""
    from fortpy.stats.bp import check_pointers
    check_pointers(parser, args["source"], args["filter"], args["recursive"])
1149611
def parse(scanner, rules, scope = ParserScope.empty)
      catch(:rule_failed) do
        return expr.parse(scanner, rules, scope)
      end
      false
    end
1329357
def _parse_boolean(element_text, state):
    """"""
    value = None

    lowered_text = element_text.lower()
    if lowered_text == 'true':
        value = True
    elif lowered_text == 'false':
        value = False
    else:
        state.raise_error(InvalidPrimitiveValue, 'Invalid boolean value "{}"'.format(element_text))

    return value
77613
def parse(self, s):
        """"""
        self._sitemaps = [ ]
        self.__rulesets = [ ]
        
        if (PY_MAJOR_VERSION > 2) and (isinstance(s, bytes) or isinstance(s, bytearray)) or \
           (PY_MAJOR_VERSION == 2) and (not isinstance(s, unicode)):            
            s = s.decode("iso-8859-1")
    
        # Normalize newlines.
        s = _end_of_line_regex.sub("\n", s)
        
        lines = s.split("\n")
        
        previous_line_was_a_user_agent = False
        current_ruleset = None
        
        for line in lines:
            line = line.strip()
            
            if line and line[0] == '#':
                # "Lines containing only a comment are discarded completely, 
                # and therefore do not indicate a record boundary." (MK1994)
                pass
            else:
                # Remove comments
                i = line.find("#")
                if i != -1: line = line[:i]
        
                line = line.strip()
                
                if not line:
                    # An empty line indicates the end of a ruleset.
                    if current_ruleset and current_ruleset.is_not_empty():
                        self.__rulesets.append(current_ruleset)
                    
                    current_ruleset = None
                    previous_line_was_a_user_agent = False
                else:
                    # Each non-empty line falls into one of six categories:
                    # 1) User-agent: blah blah blah
                    # 2) Disallow: blah blah blah
                    # 3) Allow: blah blah blah
                    # 4) Crawl-delay: blah blah blah
                    # 5) Sitemap: blah blah blah
                    # 6) Everything else
                    # 1 - 5 are interesting and I find them with the regex 
                    # below. Category 6 I discard as directed by the MK1994 
                    # ("Unrecognised headers are ignored.")
                    # Note that 4 & 5 are specific to GYM2008 syntax, but 
                    # respecting them here is not a problem. They're just 
                    # additional information the the caller is free to ignore.
                    matches = _directive_regex.findall(line)
                    
                    # Categories 1 - 5 produce two matches, #6 produces none.
                    if matches:
                        field, data = matches[0]
                        field = field.lower()
                        data = _scrub_data(data)

                        # Matching "useragent" is a deviation from the 
                        # MK1994/96 which permits only "user-agent".
                        if field in ("useragent", "user-agent"):
                            if previous_line_was_a_user_agent:
                                # Add this UA to the current ruleset 
                                if current_ruleset and data:
                                    current_ruleset.add_robot_name(data)
                            else:
                                # Save the current ruleset and start a new one.
                                if current_ruleset and current_ruleset.is_not_empty():
                                    self.__rulesets.append(current_ruleset)
                                #else:
                                    # (is_not_empty() == False) ==> malformed 
                                    # robots.txt listed a UA line but provided
                                    # no name or didn't provide any rules 
                                    # for a named UA.
                                current_ruleset = _Ruleset()
                                if data: 
                                    current_ruleset.add_robot_name(data)
                            
                            previous_line_was_a_user_agent = True
                        elif field == "allow":
                            previous_line_was_a_user_agent = False
                            if current_ruleset:
                                current_ruleset.add_allow_rule(data)
                        elif field == "sitemap":
                            previous_line_was_a_user_agent = False
                            self._sitemaps.append(data)
                        elif field == "crawl-delay":
                            # Only Yahoo documents the syntax for Crawl-delay.
                            # ref: http://help.yahoo.com/l/us/yahoo/search/webcrawler/slurp-03.html
                            previous_line_was_a_user_agent = False
                            if current_ruleset:
                                try:
                                    current_ruleset.crawl_delay = float(data)
                                except ValueError:
                                    # Invalid crawl-delay -- ignore.
                                    pass
                        else:
                            # This is a disallow line
                            previous_line_was_a_user_agent = False
                            if current_ruleset:
                                current_ruleset.add_disallow_rule(data)

        if current_ruleset and current_ruleset.is_not_empty():
            self.__rulesets.append(current_ruleset)
            
        # Now that I have all the rulesets, I want to order them in a way 
        # that makes comparisons easier later. Specifically, any ruleset that 
        # contains the default user agent '*' should go at the end of the list
        # so that I only apply the default as a last resort. According to 
        # MK1994/96, there should only be one ruleset that specifies * as the 
        # user-agent, but you know how these things go.
        not_defaults = [r for r in self.__rulesets if not r.is_default()]
        defaults = [r for r in self.__rulesets if r.is_default()]

        self.__rulesets = not_defaults + defaults
337107
function _getRule(attribute, rules) {
    rules = rules || [];

    if ( ! rules[attribute]) {
      return;
    }

    for(var i in rules[attribute]) {
      var value = rules[attribute][i];
      parsedRule = _parseRule(rule);

      if (in_array(parsedRule.rule, rules))
        return [parsedRule.rule, parsedRule.parameters];
    }
  }
954027
def parse(cls, msg):
        """"""
        lines = msg.splitlines()
        version, status_code, reason = lines[0].split()
        headers = cls.parse_headers('\r\n'.join(lines[1:]))
        return cls(version=version, status_code=status_code,
                   reason=reason, headers=headers)
1190424
@Override
    public Object parse(IGroup group, JsonRuleParser parser) {
        // rules
        BasicDBList operates = new BasicDBList();
        for (JsonRule jsonRule : group.getRules()) {
            operates.add(parser.parse(jsonRule));
        }

        // AND or OR
        BasicDBObject andOrObj = new BasicDBObject();
        andOrObj.append(EnumCondition.AND.equals(group.getCondition()) ? "$and" : "$or", operates);

        // Not
        if (group.getNot() != null && group.getNot()) {
            BasicDBList list = new BasicDBList();
            list.add(andOrObj);
            return new BasicDBObject("$nor", list);
        }
        return andOrObj;
    }
76353
def parse(s):
    """"""
    stopwatch = StopWatch()
    for line in s.splitlines():
      if line.strip():
        parts = line.split(None)
        name = parts[0]
        if name != "%":  # ie not the header line
          rest = (float(v) for v in parts[2:])
          stopwatch.times[parts[0]].merge(Stat.build(*rest))
    return stopwatch