data.py 651 B

12345678910111213141516171819202122232425
  1. from __future__ import annotations
  2. import upath.core
  3. class DataPath(upath.core.UPath):
  4. @property
  5. def parts(self):
  6. return (self.path,)
  7. def __str__(self):
  8. return self.path
  9. def with_segments(self, *pathsegments):
  10. raise NotImplementedError("path operation not supported by DataPath")
  11. def mkdir(self, mode=0o777, parents=False, exist_ok=False):
  12. raise FileExistsError(str(self))
  13. def write_bytes(self, data):
  14. raise NotImplementedError("DataPath does not support writing")
  15. def write_text(self, data, **kwargs):
  16. raise NotImplementedError("DataPath does not support writing")