Package EasyExtend :: Module eetransformer :: Class FSTransformer
[hide private]
[frames] | no frames]

Class FSTransformer



Instance Methods [hide private]
 
__init__(self)
 
maybe_remove(self, trans)
Method used to check whether a particular transformer has to be removed.
 
add_transformer(self, trans)
Adds one FiberTransformer instance.
 
nrange(self, nid)
For a node id return the corresponding node ids of all fibers currently active.
 
is_node(self, node, nid)
Used to determine whether a node has a certain node id.
 
get_handler(self, nid)
Seek for appropriate node handler using node id and ranging.
 
call_node_transformer(self, tree, handler, locals=None)
Call node transformer.
 
_find_transformable(self, tree, chain)
Used to find nodes in tree that have corresponding node transformers.
 
run(self, tree, chain=[], locals=None, prio=None)
Main transformation loop.
Method Details [hide private]

maybe_remove(self, trans)

 
Method used to check whether a particular transformer has to be removed. Remove transformer if answer is yes.
Parameters:
  • trans - Transformer instance.

add_transformer(self, trans)

 
Adds one FiberTransformer instance.
Parameters:
  • trans - Transformer instance.

is_node(self, node, nid)

 

Used to determine whether a node has a certain node id.

This method generalizes the naive check on node[0] == nid. If the node can be guaranteed to be not a Python node this check is performed directly otherwise a test on the nrange of the node id is performed.
Parameters:
  • node - node to be checked.
  • nid - node id.
Returns:
True | False

get_handler(self, nid)

 
Seek for appropriate node handler using node id and ranging.
Parameters:
  • nid - node id.
Returns:
list of node handlers for node id. Empty list if none was found.

call_node_transformer(self, tree, handler, locals=None)

 
Call node transformer.
Parameters:
  • tree - target node of transformation.
  • handler - handler corresponding to the node id.
  • locals - local context used to evaluate handler.
Returns:
one or more nodes.

run(self, tree, chain=[], locals=None, prio=None)

 
Main transformation loop. Dispatches one node to node handlers decorated by @transform. The dispatched node gets replaced by the result of the node handler.
Parameters:
  • tree - node to be dispatched.
  • chain - internally maintained node stack. Used to manage node replacments.
  • locals - dictionary that contains local context of the fiber transformation to be evaluated.
  • prio - yet unused scheduling advice. RFU.