1771
1773
real_handlers[kind](abspath, relpath)
1776
def parent_dir(path):
1777
"""same as os.path.dirname but returns '.' instead of ''
1778
for paths that just have a filename in it e.g. 'foo'"""
1779
pdir = os.path.dirname(path)
1785
def copy_ownership(dst, src):
1786
"""copy user and group ownership from own_src file/dir to dst file/dir.
1787
If own_src is None, the containing directory is used as source."""
1788
if os.name != 'posix':
1792
os.chown(dst, s.st_uid, s.st_gid)
1794
trace.warning("IOError: %s\nUnable to copy ownership from '%s' to '%s'" % (e, src, dst))
1798
def mkdir(path, ownership_src=None):
1799
"""creates the directory 'path'. If ownership_src is given, copies (chown)
1800
usr/grp ownership from 'ownership_src' to 'path'"""
1802
if ownership_src != None:
1803
copy_ownership(path, ownership_src)
1805
def open(filename, mode='r', bufsize=-1, ownership_src=None):
1806
"""This function wraps the python builtin open. filename, mode and bufsize
1807
parameters behave the same as the builtin open[1].
1808
[1] http://python.org/doc/2.6.4/library/functions.html#open"""
1810
f = __builtin__.open(filename, mode, bufsize)
1811
if ownership_src != None:
1812
copy_ownership(filename, ownership_src)
1774
1816
def path_prefix_key(path):
1775
1817
"""Generate a prefix-order path key for path.