def stats(self, path, params=None, **kwargs): """ List the stat of the actual file/directory Returns the ABFFStat object """ if ABFS.isroot(path): return ABFSStat.for_root(path) file_system, dir_name = Init_ABFS.parse_uri(path)[:2] if dir_name == '': LOG.debug("Path being called is a Filesystem") return ABFSStat.for_filesystem(self._statsf(file_system, params, **kwargs), path) return ABFSStat.for_single(self._stats(file_system + '/' +dir_name, params, **kwargs), path)
def listdir_stats(self, path, params=None, **kwargs): """ List the stats for the directories inside the specified path Returns the Multiple ABFFStat object #note change later for recursive cases """ if ABFS.isroot(path): return self.listfilesystems_stats(params=None, **kwargs) dir_stats = [] file_system, directory_name, account = Init_ABFS.parse_uri(path) root = Init_ABFS.ABFS_ROOT if path.lower().startswith(Init_ABFS.ABFS_ROOT_S): root = Init_ABFS.ABFS_ROOT_S if params is None: params = {} if 'recursive' not in params: params['recursive'] = 'false' params['resource'] = 'filesystem' if directory_name != "": params['directory'] = directory_name res = self._root._invoke("GET", file_system, params, headers=self._getheaders(), **kwargs) resp = self._root._format_response(res) if account != '': file_system = file_system + account for x in resp['paths']: dir_stats.append( ABFSStat.for_directory(res.headers, x, root + file_system + "/" + x['name'])) return dir_stats
def stats(self, path, params=None, **kwargs): """ List the stat of the actual file/directory Returns the ABFFStat object """ if ABFS.isroot(path): return ABFSStat.for_root(path) try: file_system, dir_name = Init_ABFS.parse_uri(path)[:2] except: raise IOError if dir_name == '': return ABFSStat.for_filesystem( self._statsf(file_system, params, **kwargs), path) return ABFSStat.for_single( self._stats(file_system + '/' + dir_name, params, **kwargs), path)
def listdir_stats(self, path, params=None, **kwargs): """ List the stats for the directories inside the specified path Returns the Multiple ABFFStat object #note change later for recursive cases """ if ABFS.isroot(path): LOG.warn("Path: %s is a Filesystem" % path) return self.listfilesystems_stats(params=None, **kwargs) dir_stats = [] file_system, directory_name = Init_ABFS.parse_uri(path)[:2] if params is None: params = {} if 'recursive' not in params: params['recursive'] = 'false' params['resource'] = 'filesystem' if directory_name != "": params['directory'] = directory_name res = self._root._invoke("GET", file_system, params, headers=self._getheaders(), **kwargs) resp = self._root._format_response(res) for x in resp['paths']: dir_stats.append( ABFSStat.for_directory( res.headers, x, Init_ABFS.ABFS_ROOT + file_system + "/" + x['name'])) return dir_stats
def listfilesystems_stats(self, root = Init_ABFS.ABFS_ROOT, params=None, **kwargs): """ Lists the stats inside the File Systems, No functionality for params """ stats = [] if params is None: params = {} params["resource"] = "account" res = self._root._invoke("GET", params=params, headers=self._getheaders() ) resp = self._root._format_response(res) LOG.debug("%s" % root) for x in resp['filesystems']: stats.append(ABFSStat.for_filesystems(res.headers, x, root)) return stats