def find_rule(condition):
        """
        Find rule for given condition.

        Args:
            condition (str): Python condition as string.

        Returns:
            str, list, function: found rule name, list of AST tokens for condition
                                 and verification function.
        """
        final_condition = re.sub('{{.*}}', '42', condition)
        ast_tokens = Condition.get_tokens(final_condition)
        ast_compressed_tokens = Condition.compress_tokens(ast_tokens)

        name = 'undefined'
        function = lambda tokens: False

        if len(ast_compressed_tokens) > 0:
            for rule in Condition.RULES:
                if Condition.match_tokens(ast_compressed_tokens, rule['types']):
                    name = rule['name']
                    function = rule['evaluate']
                    break
        return name, ast_tokens, function
def find_rule ( condition ) : final_condition = re . sub ( '{{.*}}' , '42' , condition ) ast_tokens = Condition . get_tokens ( final_condition ) ast_compressed_tokens = Condition . compress_tokens ( ast_tokens ) name = 'undefined' function = lambda tokens : False if len ( ast_compressed_tokens ) > 0 : for rule in Condition . RULES : if Condition . match_tokens ( ast_compressed_tokens , rule [ 'types' ] ) : name = rule [ 'name' ] function = rule [ 'evaluate' ] break return name , ast_tokens , function
Find rule for given condition.

        Args:
            condition (str): Python condition as string.

        Returns:
            str, list, function: found rule name, list of AST tokens for condition
                                 and verification function.