def _stats(self, path): """This version of stats returns None if the entry is not found""" path = Hdfs.normpath(path) params = self._getparams() params['op'] = 'GETFILESTATUS' try: json = self._root.get(path, params) return WebHdfsStat(json['FileStatus'], path) except WebHdfsException, ex: if ex.server_exc == 'FileNotFoundException' or ex.code == 404: return None raise ex
def listdir_stats(self, path, glob=None): """ listdir_stats(path, glob=None) -> [ WebHdfsStat ] Get directory listing with stats. """ path = Hdfs.normpath(path) params = self._getparams() if glob is not None: params['filter'] = glob params['op'] = 'LISTSTATUS' json = self._root.get(path, params) filestatus_list = json['FileStatuses']['FileStatus'] return [ WebHdfsStat(st, path) for st in filestatus_list ]