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  from __builtin__ import file 
 7   
 8  spacer = ' ' 
 9   
10   
11 -def plain(node, fileName=None):
12 """ 13 Plain-text dump. The hierarchy is represented through indentation. 14 """ 15 def crawl(node, depth): 16 dump(node, depth) 17 for action in node.actions.values(): 18 dump(action, depth + 1) 19 for child in node.children: 20 crawl(child, depth + 1)
21 22 def dumpFile(item, depth): 23 _file.write(spacer * depth + str(item) + '\n') 24 25 def dumpStdOut(item, depth): 26 print(spacer * depth + str(item)) 27 if fileName: 28 dump = dumpFile 29 _file = file(fileName, 'w') 30 else: 31 dump = dumpStdOut 32 33 crawl(node, 0) 34