def compile_rule(rule):
    """
    Compiles a rule in string format. Basically checks that is valid python format.
    :param rule:
    :return:
    """
    if len(rule) == 0:
        return None

    try:
        c_rule = compile(rule, "<string>", "exec")
        return c_rule
    except:
        return None