Exemple #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
Exemple #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
Exemple #3
0
def node():
    """Get as AST node from the source."""
    return parse.parse(source)
Exemple #4
0
def node():
    """Get as AST node from the source."""
    return parse.parse(source)
Exemple #5
0
def node():

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

    return parse.parse(sample_source)