def matches(filter, message, valid_paths, rule_cache, config):
if not filter['<STR_LIT>']:<EOL><INDENT>return False<EOL><DEDENT>for rule in filter['<STR_LIT>']:<EOL><INDENT>fn = rule['<STR_LIT>']<EOL>negated = rule['<STR_LIT>']<EOL>arguments = rule['<STR_LIT>']<EOL>rule_cache_key = rule['<STR_LIT>']<EOL>try:<EOL><INDENT>if rule_cache_key not in rule_cache:<EOL><INDENT>value = fn(config, message, **arguments)<EOL>if negated:<EOL><INDENT>value = not value<EOL><DEDENT>rule_cache[rule_cache_key] =  value<EOL><DEDENT>if not rule_cache[rule_cache_key]:<EOL><INDENT>return False<EOL><DEDENT><DEDENT>except Exception as e:<EOL><INDENT>log.exception(e)<EOL>return False<EOL><DEDENT><DEDENT>return True<EOL>
Returns True if the given filter matches the given message.