Exemple #1
0
def _recurse(tree, **kw):
    if type(tree) is Compare and type(tree.ops[0]) is In:
        return q((ast(tree.left)).in_(ast(tree.comparators[0])))

    elif type(tree) is GeneratorExp:

        aliases = map(f(_.target), tree.generators)
        tables = map(f(_.iter), tree.generators)

        aliased_tables = map(lambda x: q((ast(x)).alias().c), tables)

        elt = tree.elt
        if type(elt) is Tuple:
            sel = q(ast_list(elt.elts))
        else:
            sel = q([ast(elt)])

        out = q(select(ast(sel)))

        for gen in tree.generators:
            for cond in gen.ifs:
                out = q(ast(out).where(ast(cond)))


        out = q((lambda x: ast(out))())
        out.func.args.args = aliases
        out.args = aliased_tables
        return out
Exemple #2
0
def expand(tree, **kw):
    addition = 10
    return q(lambda x: x * ast(tree) + u(addition))
Exemple #3
0
def pyjs(tree, **kw):
    javascript = pjs.converter.Converter("").convert_node(tree, Scope())
    return q((ast(tree), u(javascript)))
Exemple #4
0
def query(tree, **kw):
    x = _recurse.recurse(tree)
    x = expand_let_bindings.recurse(x)
    return q((lambda query: query.bind.execute(query).fetchall())(ast(x)))
Exemple #5
0
def expand(tree, **kw):
    addition = 10
    return q(lambda x: x * ast(tree) + u(addition))