enaml.nodevisitor

Classes

NodeVisitor A base class for implementing node visitors.
class enaml.nodevisitor.NodeVisitor[source]

Bases: object

A base class for implementing node visitors.

Subclasses should implement visitor methods using the naming scheme ‘visit_<name>’ where <name> is the type name of a given node.

__call__(node)[source]

The main entry point of the visitor class.

This method should be called to execute the visitor. It will call the setup and teardown methods before and after invoking the visit method on the node.

Parameters:node (object) – The toplevel node of interest.
Returns:result – The return value from the result() method.
Return type:object
setup(node)[source]

Perform any necessary setup before running the visitor.

This method is invoked before the visitor is executed over a particular node. The default implementation does nothing.

Parameters:node (object) – The node passed to the visitor.
result(node)[source]

Get the results for the visitor.

This method is invoked after the visitor is executed over a particular node and the result() method has been called. The default implementation returns None.

Parameters:node (object) – The node passed to the visitor.
Returns:result – The results of the visitor.
Return type:object
teardown(node)[source]

Perform any necessary cleanup when the visitor is finished.

This method is invoked after the visitor is executed over a particular node and the result() method has been called. The default implementation does nothing.

Parameters:node (object) – The node passed to visitor.
visit(node)[source]

The main visitor dispatch method.

Parameters:node (object) – A node from the tree.
default_visit(node)[source]

The default node visitor method.

This method is invoked when no named visitor method is found for a given node. This default behavior raises an exception for the missing handler. Subclasses may reimplement this method for custom default behavior.

__weakref__

list of weak references to the object (if defined)