def normpath(path): """ Return normalized path but ignore leading S3_ROOT prefix if it exists """ if path.lower().startswith(S3_ROOT): if is_root(path): normalized = path else: normalized = '%s%s' % (S3_ROOT, fs_normpath(path[len(S3_ROOT):])) else: normalized = fs_normpath(path) return normalized
def normpath(path): """ Return normalized path but ignore leading S3A_ROOT prefix if it exists """ if path.lower().startswith(S3A_ROOT): if is_root(path): normalized = path else: normalized = '%s%s' % (S3A_ROOT, fs_normpath(path[len(S3A_ROOT):])) else: normalized = fs_normpath(path) return normalized
def normpath(path): """ Return the normlized path, but ignore leading prefix if it exists """ if is_root(path): return path elif path.lower().startswith(ABFS_ROOT): normalized = '%s%s' % (ABFS_ROOT, fs_normpath(path[len(ABFS_ROOT):])) elif path.lower().startswith(ABFS_ROOT_S): normalized = '%s%s' % (ABFS_ROOT_S, fs_normpath(path[len(ABFS_ROOT_S):])) else: normalized = fs_normpath(path) return normalized
def norm_path(path): path = fs_normpath(path) #fs_normpath clears scheme:/ to scheme: which doesn't make sense split = urlparse(path) if not split.path: path = split._replace(path="/").geturl() return path
def normpath(self, path): """ Return normalized path but ignore leading scheme prefix if it exists """ path = fs_normpath(path) #fs_normpath clears scheme:/ to scheme: which doesn't make sense split = urlparse(path) if not split.path: path = split._replace(path="/").geturl() return path
def __init__(self, fs, path, mode='r'): self._fs = fs self._path = fs_normpath(path) self._pos = 0 self._mode = mode try: self._stat = fs.stats(path) if self._stat.isDir: raise IOError(errno.EISDIR, _("Is a directory: '%s'") % path) except IOError, ex: if ex.errno == errno.ENOENT and 'w' in self._mode: self._fs.create(self._path) self.stat() else: raise ex
def __init__(self, fs, path, mode='r'): self._fs = fs self._path = fs_normpath(path) self._pos = 0 self._mode = mode if fs.is_web_accessible(): def read_url(fs=fs): return fs.read_url(self._path, self._pos) self.read_url = read_url try: self._stat = fs.stats(path) if self._stat.isDir: raise IOError(errno.EISDIR, _("Is a directory: '%s'") % path) except IOError as ex: if ex.errno == errno.ENOENT and 'w' in self._mode: self._fs.create(self._path) self.stat() else: raise ex