github.py 438 B

1234567891011121314151617181920212223
  1. """
  2. GitHub file system implementation
  3. """
  4. import upath.core
  5. class GitHubPath(upath.core.UPath):
  6. """
  7. GitHubPath supporting the fsspec.GitHubFileSystem
  8. """
  9. @property
  10. def path(self) -> str:
  11. pth = super().path
  12. if pth == ".":
  13. return ""
  14. return pth
  15. def iterdir(self):
  16. if self.is_file():
  17. raise NotADirectoryError(str(self))
  18. yield from super().iterdir()