Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def parent_dir(path):
- """same as os.path.dirname but returns '.' instead of ''
- for paths that just have a filename in it e.g. 'foo'"""
- pdir = os.path.dirname(path)
- if pdir == '':
- pdir = '.'
- return pdir
- def copy_ownership(dst, src):
- """copy user and group ownership from own_src file/dir to dst file/dir.
- If own_src is None, the containing directory is used as source."""
- if os.name != 'posix':
- return False
- try:
- s = os.stat(src)
- os.chown(dst, s.st_uid, s.st_gid)
- except OSError, e:
- warning("IOError: %s" % (e,))
- warning("Unable to copy ownership from '%s' to '%s'" % (src, dst))
- return True
- def mkdir(path, ownership_src=None):
- """creates the directory 'path'. If ownership_src is given, copies (chown)
- usr/grp ownership from 'ownership_src' to 'path'"""
- os.mkdir(path)
- if ownership_src != None:
- copy_ownership(path, ownership_src)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement