os.py 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. """Async executor versions of file functions from the os module."""
  2. import os
  3. from . import ospath as path
  4. from .ospath import wrap
  5. __all__ = [
  6. "path",
  7. "stat",
  8. "rename",
  9. "renames",
  10. "replace",
  11. "remove",
  12. "unlink",
  13. "mkdir",
  14. "makedirs",
  15. "rmdir",
  16. "removedirs",
  17. "symlink",
  18. "readlink",
  19. "listdir",
  20. "scandir",
  21. "access",
  22. "wrap",
  23. "getcwd",
  24. ]
  25. if hasattr(os, "link"):
  26. __all__ += ["link"]
  27. if hasattr(os, "sendfile"):
  28. __all__ += ["sendfile"]
  29. if hasattr(os, "statvfs"):
  30. __all__ += ["statvfs"]
  31. stat = wrap(os.stat)
  32. rename = wrap(os.rename)
  33. renames = wrap(os.renames)
  34. replace = wrap(os.replace)
  35. remove = wrap(os.remove)
  36. unlink = wrap(os.unlink)
  37. mkdir = wrap(os.mkdir)
  38. makedirs = wrap(os.makedirs)
  39. rmdir = wrap(os.rmdir)
  40. removedirs = wrap(os.removedirs)
  41. symlink = wrap(os.symlink)
  42. readlink = wrap(os.readlink)
  43. listdir = wrap(os.listdir)
  44. scandir = wrap(os.scandir)
  45. access = wrap(os.access)
  46. getcwd = wrap(os.getcwd)
  47. if hasattr(os, "link"):
  48. link = wrap(os.link)
  49. if hasattr(os, "sendfile"):
  50. sendfile = wrap(os.sendfile)
  51. if hasattr(os, "statvfs"):
  52. statvfs = wrap(os.statvfs)