/usr/share/pyshared/unipath/tools.py is in python-unipath 0.2.1+dfsg-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 | """Convenience functions.
"""
import sys
# Package imports.
from unipath import Path, FSPath
def dict2dir(dir, dic, mode="w"):
dir = FSPath(dir)
if not dir.exists():
dir.mkdir()
for filename, content in dic.iteritems():
p = FSPath(dir, filename)
if isinstance(content, dict):
dict2dir(p, content)
continue
f = open(p, mode)
f.write(content)
f.close()
def dump_path(path, prefix="", tab=" ", file=None):
if file is None:
file = sys.stdout
p = Path(path)
if p.islink():
print >>file, "%s%s -> %s" % (prefix, p.name, p.read_link())
elif p.isdir():
print >>file, "%s%s:" % (prefix, p.name)
for p2 in p.listdir():
dump_path(p2, prefix+tab, tab, file)
else:
print >>file, "%s%s (%d)" % (prefix, p.name, p.size())
|