rope.base.evaluate ================== .. py:module:: rope.base.evaluate Attributes ---------- .. autoapisummary:: rope.base.evaluate.BadIdentifierError Classes ------- .. autoapisummary:: rope.base.evaluate.ScopeNameFinder rope.base.evaluate.StatementEvaluator Functions --------- .. autoapisummary:: rope.base.evaluate.eval_location rope.base.evaluate.eval_location2 rope.base.evaluate.eval_node rope.base.evaluate.eval_node2 rope.base.evaluate.eval_str rope.base.evaluate.eval_str2 Module Contents --------------- .. py:data:: BadIdentifierError .. py:function:: eval_location(pymodule, offset) Find the pyname at the offset .. py:function:: eval_location2(pymodule, offset) Find the primary and pyname at offset .. py:function:: eval_node(scope, node) Evaluate a `ast.AST` node and return a PyName Return `None` if the expression cannot be evaluated. .. py:function:: eval_node2(scope, node) .. py:function:: eval_str(holding_scope, name) .. py:function:: eval_str2(holding_scope, name) .. py:class:: ScopeNameFinder(pymodule) .. py:attribute:: module_scope .. py:attribute:: lines .. py:attribute:: worder .. py:method:: get_pyname_at(offset) .. py:method:: get_primary_and_pyname_at(offset: int) -> Tuple[Optional[rope.base.pynames.PyName], Optional[rope.base.pynames.PyName]] .. py:method:: get_enclosing_function(offset) .. py:class:: StatementEvaluator(scope) Bases: :py:obj:`rope.base.ast.RopeNodeVisitor` 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:attribute:: scope .. py:attribute:: result :value: None .. py:attribute:: old_result :value: None .. py:method:: visit(node) Modified from ast.NodeVisitor to match rope's existing Visitor implementation