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():
def not_(arg): return Expr('UnaryNot', UnaryNot, expr=arg)
def not_(arg): return Expr("UnaryNot", UnaryNot, expr=arg)
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():
def and_(*args): if len(args) == 1: return args[0] return Expr('ConditionalAndExpression', ConditionalAndExpression, expr=args[0], other=list(args[1:]))