class HdfsFileManager(FileManagerBase): """A wrapper of snakebite client.""" def can_handle(self, path): return path.startswith('hdfs://') def __init__(self): self._client = AutoConfigClient() def ls(self, path: str, recursive=False) -> List[File]: files = [] for file in self._client.ls([path], recurse=recursive): if file['file_type'] == 'f': files.append(File( path=file['path'], size=file['length'])) return files def move(self, source: str, destination: str) -> bool: return len(list(self._client.rename([source], destination))) > 0 def remove(self, path: str) -> bool: return len(list(self._client.delete([path]))) > 0 def copy(self, source: str, destination: str) -> bool: # TODO raise NotImplementedError() def mkdir(self, path: str) -> bool: return next(self._client.mkdir([path], create_parent=True))\ .get('result')
class HdfsFileManager(FileManagerBase): """A wrapper of snakebite client.""" def can_handle(self, path): return path.startswith('hdfs://') def __init__(self): self._client = AutoConfigClient() def ls(self, path: str, recursive=False) -> List[str]: files = [] for file in self._client.ls([path], recurse=recursive): if file['file_type'] == 'f': files.append(file['path']) return files def move(self, source: str, destination: str) -> bool: return len(list(self._client.rename([source], destination))) > 0 def remove(self, path: str) -> bool: return len(list(self._client.delete([path]))) > 0