retrive match action and subject
543040
def relevant_rules_for_match(self, action, subject):
        """"""
        matches = []
        for rule in self.rules:
            rule.expanded_actions = self.expand_actions(rule.actions)
            if rule.is_relevant(action, subject):
                matches.append(rule)

        return self.optimize(matches[::-1])
479477
function matchAt(content, index, match) {
  return content.substring(index, index + match.length) === match;
}
901146
function matchAllowedLocalAction(text, allowedActions, actionPatterns) {
  const matched = matchAction(text, allowedActions, actionPatterns);

  if (matched) {
    // back command doesn't require a target
    if (matched.action === actions.back) {
      delete matched.objectName;
      return matched;
    }

    // Match returns empty string if command doesn't capture any objects
    if (matched.objectName === '') {
      // TODO: This section looks sketchy. Need to refactor
      if (allowedActions[matched.action].length == 1) {
        matched.object = allowedActions[matched.action][0];
      }
    } else {
      allowedActions[matched.action].forEach(object => {
        object.names.forEach(name => {
          if (name === matched.objectName) {
            matched.object = object;
          }
        })
      });
    }

    if (matched.action && matched.object) {
      delete matched.objectName;
      return matched;
    }
  }

  return undefined;
}
46873
def match(self, context, line):
		""""""
		stripped = line.stripped
		return stripped.startswith('#') and not stripped.startswith('#{')
290728
def match_all_in(self, matches, item):
        """"""
        for i, match in enumerate(matches):
            self.match(match, item + "[" + str(i) + "]")
407653
def get_match(session, match_id):
    """"""
    url = '{}{}/{}'.format(session.auth.base_url, MATCH_URL, match_id)
    parsed = make_scrape_request(session, url)
    game = parsed.find('h3').text
    if game != GAME_AOC:
        raise ValueError('not an aoc match')
    date_played = parsed.find(text=MATCH_DATE_PLAYED).find_next('td').text
    players = []
    colors = {}
    player_count = int(parsed.find('td', text='Players:').find_next('td').text)
    for div in parsed.find_all('div', style=True):
        if not div['style'].startswith('background-color:'):
            continue
        if len(players) == player_count:
            break
        username_elem = div.find_next('a', href=re.compile(PROFILE_PATH))
        username = username_elem.text
        color = div['style'].split(':')[1].split(';')[0].strip()
        colors[username] = color

        rec = None
        for dl_elem in parsed.find_all('a', href=re.compile('^/files/view')):
            rec_name = dl_elem.find('b', text=re.compile(username+'$'))
            if rec_name:
                rec = rec_name.parent

        user = parsed.find('a', text=username)
        if not user:
            # bugged match page
            continue
        user_id = int(user['href'].split('/')[-1])
        children = list(user.find_next('span').children)
        rate_after = None
        rate_before = None
        if str(children[0]).strip() == MATCH_NEW_RATE:
            rate_after = int(children[1].text)
            rate_before = rate_after - int(children[3].text)
        elif str(children[4]).strip() == MATCH_NEW_RATE:
            rate_after = int(children[5].text)
            rate_before = rate_after - int(children[3].text)
        players.append({
            'url': rec['href'] if rec else None,
            'id': user_id,
            'username': username,
            'color_id': COLOR_MAPPING.get(colors[username]),
            'rate_before': rate_before,
            'rate_after': rate_after
        })
    return {
        'timestamp': dateparser.parse(date_played),
        'players': players
    }
1142530
def is_match(self, subject: Union[Expression, FlatTerm]) -> bool:
        
        try:
            next(self.match(subject))
        except StopIteration:
            return False
        return True
769360
function match(k, v, p) {
    var re = recopy(ptn)
      , res = {key: k, value: v, parent: p, match: {key: false, value: false}};
    res.match.key = keys && re.test(k);
    res.match.value = values && re.test('' + v);
    //console.log('matches %s %s %s', matches, re, k);
    if(res.match.key || res.match.value) {
      res.pattern = ptn;
      list.push(res);
    }
  }
409537
def _get_match(self, prefix):
        
        # (hard coded) If we match a CPR response, return Keys.CPRResponse.
        # (This one doesn't fit in the ANSI_SEQUENCES, because it contains
        # integer variables.)
        if _cpr_response_re.match(prefix):
            return Keys.CPRResponse

        elif _mouse_event_re.match(prefix):
            return Keys.Vt100MouseEvent

        # Otherwise, use the mappings.
        try:
            return ANSI_SEQUENCES[prefix]
        except KeyError:
            return None
487117
def format(self, action):
        
        item = {
            'id': self.get_uri(action),
            'url': self.get_url(action),
            'verb': action.verb,
            'published': rfc3339_date(action.timestamp),
            'actor': self.format_actor(action),
            'title': text_type(action),
        }
        if action.description:
            item['content'] = action.description
        if action.target:
            item['target'] = self.format_target(action)
        if action.action_object:
            item['object'] = self.format_action_object(action)
        return item
209549
def matches_conditions?(action, subject, attribute = nil, *extra_args)
      return call_block_with_all(action, subject, extra_args) if @match_all
      return matches_block_conditions(subject, attribute, *extra_args) if @block
      return matches_non_block_conditions(subject) unless conditions_empty?

      true
    end
152266
function matchAll(exp, text) {
    exp.lastIndex = 0;
    var matches = [];
    var match;
    while ((match = exp.exec(text)) != null) {
        matches.push(match[0]);
    }
    return matches;
}
735701
def lookup_id_action(self, text, loc, var):
        """"""
        exshared.setpos(loc, text)
        if DEBUG > 0:
            print("EXP_VAR:",var)
            if DEBUG == 2: self.symtab.display()
            if DEBUG > 2: return
        var_index = self.symtab.lookup_symbol(var.name, [SharedData.KINDS.GLOBAL_VAR, SharedData.KINDS.PARAMETER, SharedData.KINDS.LOCAL_VAR])
        if var_index == None:
            raise SemanticException("'%s' undefined" % var.name)
        return var_index
995869
def matches(self, event):
        '''
        
        '''
        ret = []
        self._matches(event, set(), ret)
        return tuple(r[0] for r in ret)
482801
def match(self, subject: Expression) -> Iterator[Tuple[Expression, Substitution]]:
        
        return _MatchIter(self, subject)
1159092
def match(self, name, rdclass, rdtype, covers, deleting=None):
        """"""

        if not super(RRset, self).match(rdclass, rdtype, covers):
            return False
        if self.name != name or self.deleting != deleting:
            return False
        return True
890067
def _get_action(trans):
    
    # TODO: VIQR-like convention
    mark_action = {
        '^': (_Action.ADD_MARK, Mark.HAT),
        '+': (_Action.ADD_MARK, Mark.BREVE),
        '*': (_Action.ADD_MARK, Mark.HORN),
        '-': (_Action.ADD_MARK, Mark.BAR),
    }

    accent_action = {
        '\\': (_Action.ADD_ACCENT, Accent.GRAVE),
        '/': (_Action.ADD_ACCENT, Accent.ACUTE),
        '?': (_Action.ADD_ACCENT, Accent.HOOK),
        '~': (_Action.ADD_ACCENT, Accent.TIDLE),
        '.': (_Action.ADD_ACCENT, Accent.DOT),
    }

    if trans[0] in ('<', '+'):
        return _Action.ADD_CHAR, trans[1]
    if trans[0] == "_":
        return _Action.UNDO, trans[1:]
    if len(trans) == 2:
        return mark_action[trans[1]]
    else:
        return accent_action[trans[0]]