rope.refactor.patchedast ======================== .. py:module:: rope.refactor.patchedast Attributes ---------- .. autoapisummary:: rope.refactor.patchedast.COMMA_IN_WITH_PATTERN Exceptions ---------- .. autoapisummary:: rope.refactor.patchedast.MismatchedTokenError Functions --------- .. autoapisummary:: rope.refactor.patchedast.get_patched_ast rope.refactor.patchedast.patch_ast rope.refactor.patchedast.node_region rope.refactor.patchedast.write_ast Module Contents --------------- .. py:data:: COMMA_IN_WITH_PATTERN .. py:function:: 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. .. py:function:: 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. .. py:function:: node_region(patched_ast_node) Get the region of a patched ast node .. py:function:: 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. .. py:exception:: MismatchedTokenError Bases: :py:obj:`rope.base.exceptions.RopeError` Base exception for rope