Package dogtail :: Module dump
[hide private]
[frames] | no frames]

Source Code for Module dogtail.dump

 1  """Utility functions for 'dumping' trees of Node objects. 
 2   
 3  Author: Zack Cerza <zcerza@redhat.com>""" 
 4  __author__ = "Zack Cerza <zcerza@redhat.com>" 
 5   
 6  spacer = ' ' 
7 -def plain (node, fileName = None):
8 """ 9 Plain-text dump. The hierarchy is represented through indentation. 10 """ 11 def crawl(node, depth): 12 dump(node, depth) 13 for action in node.actions.values(): 14 dump(action, depth + 1) 15 for child in node.children: 16 crawl(child, depth + 1)
17 18 def dumpFile(item, depth): _file.write(spacer*depth + str(item) + '\n') 19 def dumpStdOut(item, depth): print spacer*depth + str(item) 20 if fileName: 21 dump = dumpFile 22 _file = file(fileName, 'w') 23 else: dump = dumpStdOut 24 25 crawl(node, 0) 26