rope.base.ast ============= .. py:module:: rope.base.ast Classes ------- .. autoapisummary:: rope.base.ast.RopeNodeVisitor Functions --------- .. autoapisummary:: rope.base.ast.parse rope.base.ast.call_for_nodes rope.base.ast.get_const_subtype_name rope.base.ast.get_node_type_name Module Contents --------------- .. py:function:: parse(source, filename='', *args, **kwargs) .. py:function:: call_for_nodes(node, callback) Pre-order depth-first traversal of AST nodes, calling `callback(node)` for each node visited. When each node is visited, `callback(node)` will be called with the visited `node`, then its children node will be visited. If `callback(node)` returns `True` for a node, then the descendants of that node will not be visited. See _ResultChecker._find_node for an example. .. py:class:: RopeNodeVisitor Bases: :py:obj:`ast.NodeVisitor` A node visitor base class that walks the abstract syntax tree and calls a visitor function for every node found. This function may return a value which is forwarded by the `visit` method. This class is meant to be subclassed, with the subclass adding visitor methods. Per default the visitor functions for the nodes are ``'visit_'`` + class name of the node. So a `TryFinally` node visit function would be `visit_TryFinally`. This behavior can be changed by overriding the `visit` method. If no visitor function exists for a node (return value `None`) the `generic_visit` visitor is used instead. Don't use the `NodeVisitor` if you want to apply changes to nodes during traversing. For this a special visitor exists (`NodeTransformer`) that allows modifications. .. py:method:: visit(node) Modified from ast.NodeVisitor to match rope's existing Visitor implementation .. py:function:: get_const_subtype_name(node) Get pre-3.8 ast node name .. py:function:: get_node_type_name(node)