Package gavo :: Package adql :: Module morphhelpers :: Class Morpher
[frames] | no frames]

Class Morpher

source code

object --+
         |
        Morpher

A class managing the process of morphing an ADQL expression.

It is constructed with a a dictionary of morphers; the keys are node types, the values morphing functions.

Morphing functions have the signature m(node, state) -> node. They should return the node if they do not with to change it. state is a State instance.

The main entry point is morph(origTree) -> state, tree. origTree is not modified, the return value can be flattened but can otherwise be severely damaged.

For special effects, there's also earlyMorphers. These will be called when traversal reaches the node for the first time. If these return None, traversal continues as usual, if not, their result will be added to the tree and *not* further traversed.

Instance Methods
 
__init__(self, morphers, earlyMorphers={})
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
morph(self, tree) source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties

Inherited from object: __class__

Method Details

__init__(self, morphers, earlyMorphers={})
(Constructor)

source code 

x.__init__(...) initializes x; see help(type(x)) for signature

Overrides: object.__init__
(inherited documentation)