示例#1
0
def big_ast():
    """Generate a large AST."""
    # Trickery to get the path of a near-by file.
    file_path = os.path.join(
        os.path.dirname(os.path.realpath(__file__)),
        'test_name.py',
    )

    with open(file_path, 'r') as source_file:

        node = parse.parse(source_file.read())

    # Duplicate the body several times.
    for x in range(5):

        node.body.extend(node.body)

    return node
示例#2
0
def big_ast():
    """Generate a large AST."""
    # Trickery to get the path of a near-by file.
    file_path = os.path.join(
        os.path.dirname(
            os.path.realpath(__file__)
        ),
        'test_name.py',
    )

    with open(file_path, 'r') as source_file:

        node = parse.parse(source_file.read())

    # Duplicate the body several times.
    for x in range(5):

        node.body.extend(node.body)

    return node
示例#3
0
def node():
    """Get as AST node from the source."""
    return parse.parse(source)
示例#4
0
def node():
    """Get as AST node from the source."""
    return parse.parse(source)
示例#5
0
def node():

    return parse.parse(names_source)
示例#6
0
def node():

    return parse.parse(sample_source)