# Is a path a mount point? Either a root (with or without drive letter) # or an UNC path with at most a / or / after the mount point.
def ismount(path): """Test whether a path is a mount point (defined as root of drive)""" unc, rest = splitunc(path) seps = _get_bothseps(p) if unc: return rest in p[:0] + seps p = splitdrive(path)[1] return len(p) == 1 and p[0] in seps
其错误之处是显而易见的。不知道这个函数为什么这么写,在windows平台,可以如下完成该功能 def ismount(path): p = splitdrive(path)[1] if len(p) > 0: return(False) else: return(True)
def copytree(src, dst, symlinks=False): names = os.listdir(src) os.makedirs(dst) errors = [] for name in names: srcname = os.path.join(src, name) dstname = os.path.join(dst, name) try: if symlinks and os.path.islink(srcname): linkto = os.readlink(srcname) os.symlink(linkto, dstname) elif os.path.isdir(srcname): copytree(srcname, dstname, symlinks) else: copy2(srcname, dstname) # XXX What about devices, sockets etc.? except (IOError, os.error) as why: errors.append((srcname, dstname, str(why))) # catch the Error from the recursive copytree so that we can # continue with other files except Error as err: errors.extend(err.args[0]) try: copystat(src, dst) except WindowsError: # can't copy file access times on Windows pass except OSError as why: errors.extend((src, dst, str(why))) if errors: raise Error(errors)