Example #1
0
def build_if():
    test = menu('test')['test']
    test = ast.parse(test).body[0].value
    add_ast_node(_ast.If(
        test=test,
        body=[],
        orelse=[],
    ))
Example #2
0
def build_if():
    test = menu('test')['test']
    test = ast.parse(test).body[0].value
    add_ast_node(_ast.If(
        test=test,
        body=[],
        orelse=[],
    ))
Example #3
0
def build_for():
    config = menu("target", "iterable")
    target = _ast.Name(id=config["target"])
    iterable = ast.parse(config["iterable"]).body[0].value
    add_ast_node(_ast.For(
        target=target,
        iter=iterable,
        body=[],
        orelse=[],
    ))
Example #4
0
def build_function():
    config = menu('name')
    name = config['name']
    function = _ast.FunctionDef(name=name, args=[], defaults=[], body=[], decorator_list=[])
    add_ast_node(function)
    parent = globals['node']
    for child in parent.children:
        if (child.node == function):
            globals['node'] = child
            break
Example #5
0
def build_for():
    config = menu("target", "iterable")
    target = _ast.Name(id=config["target"])
    iterable = ast.parse(config["iterable"]).body[0].value
    add_ast_node(_ast.For(
        target=target,
        iter=iterable,
        body=[],
        orelse=[],
    ))
Example #6
0
def build_function():
    config = menu('name')
    name = config['name']
    function = _ast.FunctionDef(name=name,
                                args=[],
                                defaults=[],
                                body=[],
                                decorator_list=[])
    add_ast_node(function)
    parent = globals['node']
    for child in parent.children:
        if (child.node == function):
            globals['node'] = child
            break
Example #7
0
def build_expr():
    expression = menu('expression')['expression']
    expression = ast.parse(expression).body[0]
    add_ast_node(expression)
Example #8
0
def build_import():
    module = menu('module')['module']
    add_ast_node(_ast.Import(names=[_ast.alias(name=module, asname=None)]))
Example #9
0
def build_expr():
    expression = menu('expression')['expression']
    expression = ast.parse(expression).body[0]
    add_ast_node(expression)
Example #10
0
def build_import():
    module = menu('module')['module']
    add_ast_node(_ast.Import(names=[_ast.alias(name=module, asname=None)]))