Exemple #1
0
def make_query(args, frame_depth=3):
    gen, globals, locals = get_globals_and_locals(args,
                                                  kwargs=None,
                                                  frame_depth=frame_depth + 1,
                                                  from_generator=True)
    tree, external_names, cells = decompile(gen)
    code_key = ic.set(gen.gi_frame.f_code)
    return QueryFactory(code_key, tree.code, globals, locals, cells)
Exemple #2
0
def select(*args):
    assert len(args) > 0, 'select take at least one argument!'
    gen, globals, locals = get_globals_and_locals(
        args, kwargs=None, frame_depth=3,
        from_generator=isinstance(args[0], types.GeneratorType))
    tree, external_names, cells = decompile(gen)
    scope = dict(globals)
    scope.update(locals)
    factory = ast2factory(tree.code, scope)
    return factory()
Exemple #3
0
def select(*args):
    gen, globals, locals = get_globals_and_locals(args,
                                                  kwargs=None,
                                                  frame_depth=3,
                                                  from_generator=True)
    tree, external_names, cells = decompile(gen)
    scope = dict(globals)
    scope.update(locals)
    factory = ast2factory(tree.code, scope)
    return factory()