rope.refactor.patchedast

Attributes

COMMA_IN_WITH_PATTERN

Exceptions

MismatchedTokenError

Base exception for rope

Functions

get_patched_ast(source[, sorted_children])

Adds region and sorted_children fields to nodes

patch_ast(node, source[, sorted_children])

Patches the given node

node_region(patched_ast_node)

Get the region of a patched ast node

write_ast(patched_ast_node)

Extract source form a patched AST node with sorted_children field

Module Contents

rope.refactor.patchedast.COMMA_IN_WITH_PATTERN
rope.refactor.patchedast.get_patched_ast(source, sorted_children=False)

Adds region and sorted_children fields to nodes

Adds sorted_children field only if sorted_children is True.

rope.refactor.patchedast.patch_ast(node, source, sorted_children=False)

Patches the given node

After calling, each node in node will have a new field named region that is a tuple containing the start and end offsets of the code that generated it.

If sorted_children is true, a sorted_children field will be created for each node, too. It is a list containing child nodes as well as whitespaces and comments that occur between them.

rope.refactor.patchedast.node_region(patched_ast_node)

Get the region of a patched ast node

rope.refactor.patchedast.write_ast(patched_ast_node)

Extract source form a patched AST node with sorted_children field

If the node is patched with sorted_children turned off you can use node_region function for obtaining code using module source code.

exception rope.refactor.patchedast.MismatchedTokenError

Bases: rope.base.exceptions.RopeError

Base exception for rope