/usr/lib/python2.7/dist-packages/dogtail/dump.py is in python-dogtail 0.9.9-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | # -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function, unicode_literals
"""
Utility functions for 'dumping' trees of Node objects.
"""
__author__ = "Zack Cerza <zcerza@redhat.com>"
spacer = ' '
def plain(node, fileName=None):
"""
Plain-text dump. The hierarchy is represented through indentation.
"""
def crawl(node, depth):
dump(node, depth)
for action in list(node.actions.values()):
dump(action, depth + 1)
for child in node.children:
crawl(child, depth + 1)
def dumpFile(item, depth):
_file.write(str(spacer * depth) + str(item) + str('\n'))
def dumpStdOut(item, depth):
try:
print(spacer * depth + str(item))
except UnicodeDecodeError:
print(spacer * depth + str(item).decode('utf8'))
if fileName:
dump = dumpFile
_file = open(fileName, 'w')
else:
dump = dumpStdOut
crawl(node, 0)
|