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