zipio.rst 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. :mod:`modulegraph.zipio` --- Read-only filesystem access
  2. ========================================================
  3. .. module:: modulegraph.zipio
  4. :synopsis: Read-only filesystem access with ZIP support
  5. This module contains a number of functions that mirror functions found
  6. in :mod:`os` and :mod:`os.path`, but have support for data inside
  7. zipfiles as well as regular filesystem objects.
  8. The *path* argument of all functions below can refer to an object
  9. on the filesystem, but can also refer to an entry inside a zipfile. In
  10. the latter case, a prefix of *path* will be the name of zipfile while
  11. the rest refers to an object in that zipfile. As an example, when
  12. ``somepath/mydata.zip`` is a zipfile the path ``somepath/mydata.zip/somefile.txt``
  13. will refer to ``somefile.txt`` inside the zipfile.
  14. .. function:: open(path[, mode])
  15. Open a file, like :func:`the built-in open function <__builtin__.open>`.
  16. The *mode* defaults to ``"r"`` and must be either ``"r"`` or ``"rb"``.
  17. .. function:: listdir(path)
  18. List the contents of a directory, like :func:`os.listdir`.
  19. .. function:: isfile(path)
  20. Returns true if *path* exists and refers to a file.
  21. Raises IOError when *path* doesn't exist at all.
  22. Based on :func:`os.path.isfile`
  23. .. function:: isdir(path)
  24. Returns true if *path* exists and refers to a directory.
  25. Raises IOError when *path* doesn't exist at all.
  26. Based on :func:`os.path.isdir`
  27. .. function:: islink(path)
  28. Returns true if *path* exists and refers to a symbolic link.
  29. Raises IOError when *path* doesn't exist at all.
  30. Based on :func:`os.path.islink`
  31. .. function:: readlink(path)
  32. Returns the contents of a symbolic link, like :func:`os.readlink`.
  33. .. function:: getmtime(path)
  34. Returns the last modifiction time of a file or directory, like
  35. :func:`os.path.getmtime`.
  36. .. function:: getmode(path)
  37. Returns the UNIX file mode for a file or directory, like the
  38. *st_mode* attribute in the result of :func:`os.stat`.