hdfs.py 623 B

1234567891011121314151617181920212223
  1. from __future__ import annotations
  2. from upath._compat import FSSpecAccessorShim as _FSSpecAccessorShim
  3. from upath.core import UPath
  4. __all__ = ["HDFSPath"]
  5. # accessors are deprecated
  6. _HDFSAccessor = _FSSpecAccessorShim
  7. class HDFSPath(UPath):
  8. __slots__ = ()
  9. def mkdir(self, mode=0o777, parents=False, exist_ok=False):
  10. if not exist_ok and self.exists():
  11. raise FileExistsError(str(self))
  12. super().mkdir(mode=mode, parents=parents, exist_ok=exist_ok)
  13. def iterdir(self):
  14. if self.is_file():
  15. raise NotADirectoryError(str(self))
  16. yield from super().iterdir()