Exemple #1
0
    return Expr("UnaryNot", UnaryNot, expr=arg)


def and_(*args):
    if len(args) == 1:
        return args[0]

    return Expr(
        "ConditionalAndExpression",
        ConditionalAndExpression,
        expr=args[0],
        other=list(args[1:]),
    )


TrueFilter = Expr("TrueFilter", lambda _1, _2: Literal(True))


def simplify(expr):
    if isinstance(expr, ParseResults) and len(expr) == 1:
        return simplify(expr[0])

    if isinstance(expr, (list, ParseResults)):
        return list(map(simplify, expr))
    if not isinstance(expr, CompValue):
        return expr
    if expr.name.endswith("Expression"):
        if expr.other is None:
            return simplify(expr.expr)

    for k in expr.keys():
Exemple #2
0
def not_(arg):
    return Expr('UnaryNot', UnaryNot, expr=arg)
Exemple #3
0
def not_(arg):
    return Expr("UnaryNot", UnaryNot, expr=arg)
Exemple #4
0
def not_(arg):
    return Expr('UnaryNot', UnaryNot, expr=arg)


def and_(*args):
    if len(args) == 1:
        return args[0]

    return Expr('ConditionalAndExpression',
                ConditionalAndExpression,
                expr=args[0],
                other=list(args[1:]))


TrueFilter = Expr('TrueFilter', lambda _1, _2: Literal(True))


def simplify(expr):
    if isinstance(expr, ParseResults) and len(expr) == 1:
        return simplify(expr[0])

    if isinstance(expr, (list, ParseResults)):
        return map(simplify, expr)
    if not isinstance(expr, CompValue):
        return expr
    if expr.name.endswith('Expression'):
        if expr.other is None:
            return simplify(expr.expr)

    for k in expr.keys():
Exemple #5
0
def and_(*args):
    if len(args) == 1:
        return args[0]

    return Expr('ConditionalAndExpression', ConditionalAndExpression,
                expr=args[0], other=list(args[1:]))