def METHOD_NAME(action):
    types = set()
    attrs = {}
    for rule in rules:
        # Try to match the regex.
        m = re.search(rule.regex, action)
        if m or (rule.regex in action):
            # If so, apply its associated types to this action.
            types |= rule.types
            # Also add its specified attrs.
            attrs.update(m.groupdict())
            attrs.update(rule.attrs)
            # Break if the rule says so, otherwise continue testing against
            # other rules.
            if rule.stop is True:
                break
    # Returns types, attrs
    return list(types), attrs