def listdirinfo(self, path="./", wildcard=None, full=False, absolute=False, dirs_only=False, files_only=False): npath = self._normpath(path) try: attrs = self.client.listdir_attr(npath) attrs_map = dict((a.filename, a) for a in attrs) paths = list(attrs_map.keys()) except IOError as e: if getattr(e, "errno", None) == ENOENT: if self.isfile(path): raise ResourceInvalidError( path, msg="Can't list directory contents of a file: %(path)s" ) raise ResourceNotFoundError(path) elif self.isfile(path): raise ResourceInvalidError( path, msg="Can't list directory contents of a file: %(path)s") raise if dirs_only: filter_paths = [] for path, attr in attrs_map.items(): if isdir(self, path, attr.__dict__): filter_paths.append(path) paths = filter_paths elif files_only: filter_paths = [] for path, attr in attrs_map.items(): if isfile(self, path, attr.__dict__): filter_paths.append(path) paths = filter_paths for (i, p) in enumerate(paths): if not isinstance(p, str): paths[i] = p.decode(self.encoding) def getinfo(p): resourcename = basename(p) info = attrs_map.get(resourcename) if info is None: return self.getinfo(pathjoin(path, p)) return self._extract_info(info.__dict__) return [(p, getinfo(p)) for p in self._listdir_helper( path, paths, wildcard, full, absolute, False, False)]
raise ResourceNotFoundError(path) elif self.isfile(path): raise ResourceInvalidError(path,msg="Can't list directory contents of a file: %(path)s") raise if attrs_map: if dirs_only: filter_paths = [] for apath, attr in attrs_map.iteritems(): if isdir(self, path, attr.__dict__): filter_paths.append(apath) paths = filter_paths elif files_only: filter_paths = [] for apath, attr in attrs_map.iteritems(): if isfile(self, apath, attr.__dict__): filter_paths.append(apath) paths = filter_paths for (i,p) in enumerate(paths): if not isinstance(p,unicode): paths[i] = p.decode(self.encoding) return self._listdir_helper(path, paths, wildcard, full, absolute, False, False) @synchronize @convert_os_errors def listdirinfo(self,path="./",wildcard=None,full=False,absolute=False,dirs_only=False,files_only=False): npath = self._normpath(path) try: attrs = self.client.listdir_attr(npath)