Mercurial > cpython-lru_cache-weakref
annotate Doc/lib/libzipfile.tex @ 21467:4e35fa5d5708 legacy-trunk
Add documentation for the help() built-in; contributed by Ka-Ping Yee.
This is part of SF patch #494622.
| author | Fred Drake <fdrake@acm.org> |
|---|---|
| date | Tue, 18 Dec 2001 16:31:08 +0000 |
| parents | 33b4357aebb8 |
| children | ec6b67d2803d |
| rev | line source |
|---|---|
| 12198 | 1 \section{\module{zipfile} --- |
| 2 Work with ZIP archives} | |
| 3 | |
|
14661
e7f73d35ecd8
Add missing \declaremodule for zipfile.
Fred Drake <fdrake@acm.org>
parents:
14451
diff
changeset
|
4 \declaremodule{standard}{zipfile} |
| 12198 | 5 \modulesynopsis{Read and write ZIP-format archive files.} |
| 6 \moduleauthor{James C. Ahlstrom}{jim@interet.com} | |
| 7 \sectionauthor{James C. Ahlstrom}{jim@interet.com} | |
| 8 % LaTeX markup by Fred L. Drake, Jr. <fdrake@acm.org> | |
| 9 | |
|
14451
e5cdce2a2b16
Added note about Python version this was added for.
Fred Drake <fdrake@acm.org>
parents:
12198
diff
changeset
|
10 \versionadded{1.6} |
|
e5cdce2a2b16
Added note about Python version this was added for.
Fred Drake <fdrake@acm.org>
parents:
12198
diff
changeset
|
11 |
| 12198 | 12 The ZIP file format is a common archive and compression standard. |
| 13 This module provides tools to create, read, write, append, and list a | |
|
14974
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
14 ZIP file. Any advanced use of this module will require an |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
15 understanding of the format, as defined in |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
16 \citetitle[http://www.pkware.com/appnote.html]{PKZIP Application |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
17 Note}. |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
18 |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
19 This module does not currently handle ZIP files which have appended |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
20 comments, or multi-disk ZIP files. |
| 12198 | 21 |
| 22 The available attributes of this module are: | |
| 23 | |
| 24 \begin{excdesc}{error} | |
| 25 The error raised for bad ZIP files. | |
| 26 \end{excdesc} | |
| 27 | |
|
17780
a1575dbf7d81
Replace "\begin{classdesc}{SomeClass}{\unspecified}" with
Fred Drake <fdrake@acm.org>
parents:
17739
diff
changeset
|
28 \begin{classdesc*}{ZipFile} |
| 12198 | 29 The class for reading and writing ZIP files. See |
| 30 ``\citetitle{ZipFile Objects}'' (section \ref{zipfile-objects}) for | |
| 31 constructor details. | |
| 17785 | 32 \end{classdesc*} |
| 12198 | 33 |
|
17780
a1575dbf7d81
Replace "\begin{classdesc}{SomeClass}{\unspecified}" with
Fred Drake <fdrake@acm.org>
parents:
17739
diff
changeset
|
34 \begin{classdesc*}{PyZipFile} |
|
14974
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
35 Class for creating ZIP archives containing Python libraries. |
| 17785 | 36 \end{classdesc*} |
|
14974
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
37 |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
38 \begin{classdesc}{ZipInfo}{\optional{filename\optional{, date_time}}} |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
39 Class used the represent infomation about a member of an archive. |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
40 Instances of this class are returned by the \method{getinfo()} and |
|
14990
bb6cca57eb8b
Jim Ahlstrom sent a few corrections to my changes. (Thanks!)
Fred Drake <fdrake@acm.org>
parents:
14974
diff
changeset
|
41 \method{infolist()} methods of \class{ZipFile} objects. Most users |
|
14974
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
42 of the \module{zipfile} module will not need to create these, but |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
43 only use those created by this module. |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
44 \var{filename} should be the full name of the archive member, and |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
45 \var{date_time} should be a tuple containing six fields which |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
46 describe the time of the last modification to the file; the fields |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
47 are described in section \ref{zipinfo-objects}, ``ZipInfo Objects.'' |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
48 \end{classdesc} |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
49 |
|
15045
c90c3aabd8f5
is_zipfile() description: Use the same name for the parameter as the
Fred Drake <fdrake@acm.org>
parents:
14990
diff
changeset
|
50 \begin{funcdesc}{is_zipfile}{filename} |
|
c90c3aabd8f5
is_zipfile() description: Use the same name for the parameter as the
Fred Drake <fdrake@acm.org>
parents:
14990
diff
changeset
|
51 Returns true if \var{filename} is a valid ZIP file based on its magic |
| 12198 | 52 number, otherwise returns false. This module does not currently |
| 53 handle ZIP files which have appended comments. | |
| 54 \end{funcdesc} | |
| 55 | |
| 56 \begin{datadesc}{ZIP_STORED} | |
|
15045
c90c3aabd8f5
is_zipfile() description: Use the same name for the parameter as the
Fred Drake <fdrake@acm.org>
parents:
14990
diff
changeset
|
57 The numeric constant for an uncompressed archive member. |
| 12198 | 58 \end{datadesc} |
| 59 | |
| 60 \begin{datadesc}{ZIP_DEFLATED} | |
| 61 The numeric constant for the usual ZIP compression method. This | |
| 62 requires the zlib module. No other compression methods are | |
| 63 currently supported. | |
| 64 \end{datadesc} | |
| 65 | |
| 66 | |
| 67 \begin{seealso} | |
|
14934
3da99f0c184f
Replace to XXX notes to add references with real references.
Fred Drake <fdrake@acm.org>
parents:
14661
diff
changeset
|
68 \seetitle[http://www.pkware.com/appnote.html]{PKZIP Application |
|
3da99f0c184f
Replace to XXX notes to add references with real references.
Fred Drake <fdrake@acm.org>
parents:
14661
diff
changeset
|
69 Note}{Documentation on the ZIP file format by Phil |
|
3da99f0c184f
Replace to XXX notes to add references with real references.
Fred Drake <fdrake@acm.org>
parents:
14661
diff
changeset
|
70 Katz, the creator of the format and algorithms used.} |
|
3da99f0c184f
Replace to XXX notes to add references with real references.
Fred Drake <fdrake@acm.org>
parents:
14661
diff
changeset
|
71 |
|
3da99f0c184f
Replace to XXX notes to add references with real references.
Fred Drake <fdrake@acm.org>
parents:
14661
diff
changeset
|
72 \seetitle[http://www.info-zip.org/pub/infozip/]{Info-ZIP Home Page}{ |
|
3da99f0c184f
Replace to XXX notes to add references with real references.
Fred Drake <fdrake@acm.org>
parents:
14661
diff
changeset
|
73 Information about the Info-ZIP project's ZIP archive |
|
3da99f0c184f
Replace to XXX notes to add references with real references.
Fred Drake <fdrake@acm.org>
parents:
14661
diff
changeset
|
74 programs and development libraries.} |
| 12198 | 75 \end{seealso} |
| 76 | |
| 77 | |
| 78 \subsection{ZipFile Objects \label{zipfile-objects}} | |
| 79 | |
|
17739
f971f252d9b8
Itamar Shtull-Trauring <python@itamarst.org>:
Fred Drake <fdrake@acm.org>
parents:
15154
diff
changeset
|
80 \begin{classdesc}{ZipFile}{file\optional{, mode\optional{, compression}}} |
|
f971f252d9b8
Itamar Shtull-Trauring <python@itamarst.org>:
Fred Drake <fdrake@acm.org>
parents:
15154
diff
changeset
|
81 Open a ZIP file, where \var{file} can be either a path to a file |
|
18416
33b4357aebb8
Fix up a few style nits -- avoid "e.g." and "i.e." -- these make
Fred Drake <fdrake@acm.org>
parents:
17785
diff
changeset
|
82 (a string) or a file-like object. The \var{mode} parameter |
| 12198 | 83 should be \code{'r'} to read an existing file, \code{'w'} to |
| 84 truncate and write a new file, or \code{'a'} to append to an | |
|
17739
f971f252d9b8
Itamar Shtull-Trauring <python@itamarst.org>:
Fred Drake <fdrake@acm.org>
parents:
15154
diff
changeset
|
85 existing file. For \var{mode} is \code{'a'} and \var{file} |
| 12198 | 86 refers to an existing ZIP file, then additional files are added to |
|
17739
f971f252d9b8
Itamar Shtull-Trauring <python@itamarst.org>:
Fred Drake <fdrake@acm.org>
parents:
15154
diff
changeset
|
87 it. If \var{file} does not refer to a ZIP file, then a new ZIP |
| 12198 | 88 archive is appended to the file. This is meant for adding a ZIP |
| 89 archive to another file, such as \file{python.exe}. Using | |
|
14974
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
90 |
| 12198 | 91 \begin{verbatim} |
| 92 cat myzip.zip >> python.exe | |
| 93 \end{verbatim} | |
|
14974
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
94 |
| 12198 | 95 also works, and at least \program{WinZip} can read such files. |
| 96 \var{compression} is the ZIP compression method to use when writing | |
| 97 the archive, and should be \constant{ZIP_STORED} or | |
| 98 \constant{ZIP_DEFLATED}; unrecognized values will cause | |
|
14990
bb6cca57eb8b
Jim Ahlstrom sent a few corrections to my changes. (Thanks!)
Fred Drake <fdrake@acm.org>
parents:
14974
diff
changeset
|
99 \exception{RuntimeError} to be raised. If \constant{ZIP_DEFLATED} |
|
bb6cca57eb8b
Jim Ahlstrom sent a few corrections to my changes. (Thanks!)
Fred Drake <fdrake@acm.org>
parents:
14974
diff
changeset
|
100 is specified but the \refmodule{zlib} module is not avaialble, |
|
bb6cca57eb8b
Jim Ahlstrom sent a few corrections to my changes. (Thanks!)
Fred Drake <fdrake@acm.org>
parents:
14974
diff
changeset
|
101 \exception{RuntimeError} is also raised. The default is |
| 12198 | 102 \constant{ZIP_STORED}. |
| 103 \end{classdesc} | |
| 104 | |
|
14990
bb6cca57eb8b
Jim Ahlstrom sent a few corrections to my changes. (Thanks!)
Fred Drake <fdrake@acm.org>
parents:
14974
diff
changeset
|
105 \begin{methoddesc}{close}{} |
|
bb6cca57eb8b
Jim Ahlstrom sent a few corrections to my changes. (Thanks!)
Fred Drake <fdrake@acm.org>
parents:
14974
diff
changeset
|
106 Close the archive file. You must call \method{close()} before |
|
bb6cca57eb8b
Jim Ahlstrom sent a few corrections to my changes. (Thanks!)
Fred Drake <fdrake@acm.org>
parents:
14974
diff
changeset
|
107 exiting your program or essential records will not be written. |
|
bb6cca57eb8b
Jim Ahlstrom sent a few corrections to my changes. (Thanks!)
Fred Drake <fdrake@acm.org>
parents:
14974
diff
changeset
|
108 \end{methoddesc} |
|
bb6cca57eb8b
Jim Ahlstrom sent a few corrections to my changes. (Thanks!)
Fred Drake <fdrake@acm.org>
parents:
14974
diff
changeset
|
109 |
|
bb6cca57eb8b
Jim Ahlstrom sent a few corrections to my changes. (Thanks!)
Fred Drake <fdrake@acm.org>
parents:
14974
diff
changeset
|
110 \begin{methoddesc}{getinfo}{name} |
|
bb6cca57eb8b
Jim Ahlstrom sent a few corrections to my changes. (Thanks!)
Fred Drake <fdrake@acm.org>
parents:
14974
diff
changeset
|
111 Return a \class{ZipInfo} object with information about the archive |
|
bb6cca57eb8b
Jim Ahlstrom sent a few corrections to my changes. (Thanks!)
Fred Drake <fdrake@acm.org>
parents:
14974
diff
changeset
|
112 member \var{name}. |
|
bb6cca57eb8b
Jim Ahlstrom sent a few corrections to my changes. (Thanks!)
Fred Drake <fdrake@acm.org>
parents:
14974
diff
changeset
|
113 \end{methoddesc} |
|
bb6cca57eb8b
Jim Ahlstrom sent a few corrections to my changes. (Thanks!)
Fred Drake <fdrake@acm.org>
parents:
14974
diff
changeset
|
114 |
|
14974
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
115 \begin{methoddesc}{infolist}{} |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
116 Return a list containing a \class{ZipInfo} object for each member of |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
117 the archive. The objects are in the same order as their entries in |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
118 the actual ZIP file on disk if an existing archive was opened. |
| 12198 | 119 \end{methoddesc} |
| 120 | |
|
15154
1730591d5d5d
Make sure methods of ZipFile objects are in alphabetical order; the logical
Fred Drake <fdrake@acm.org>
parents:
15045
diff
changeset
|
121 \begin{methoddesc}{namelist}{} |
|
1730591d5d5d
Make sure methods of ZipFile objects are in alphabetical order; the logical
Fred Drake <fdrake@acm.org>
parents:
15045
diff
changeset
|
122 Return a list of archive members by name. |
|
1730591d5d5d
Make sure methods of ZipFile objects are in alphabetical order; the logical
Fred Drake <fdrake@acm.org>
parents:
15045
diff
changeset
|
123 \end{methoddesc} |
|
1730591d5d5d
Make sure methods of ZipFile objects are in alphabetical order; the logical
Fred Drake <fdrake@acm.org>
parents:
15045
diff
changeset
|
124 |
| 12198 | 125 \begin{methoddesc}{printdir}{} |
|
14974
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
126 Print a table of contents for the archive to \code{sys.stdout}. |
| 12198 | 127 \end{methoddesc} |
| 128 | |
| 129 \begin{methoddesc}{read}{name} | |
| 130 Return the bytes of the file in the archive. The archive must be | |
| 131 open for read or append. | |
| 132 \end{methoddesc} | |
| 133 | |
|
14974
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
134 \begin{methoddesc}{testzip}{} |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
135 Read all the files in the archive and check their CRC's. Return the |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
136 name of the first bad file, or else return \code{None}. |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
137 \end{methoddesc} |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
138 |
|
14990
bb6cca57eb8b
Jim Ahlstrom sent a few corrections to my changes. (Thanks!)
Fred Drake <fdrake@acm.org>
parents:
14974
diff
changeset
|
139 \begin{methoddesc}{write}{filename\optional{, arcname\optional{, |
|
bb6cca57eb8b
Jim Ahlstrom sent a few corrections to my changes. (Thanks!)
Fred Drake <fdrake@acm.org>
parents:
14974
diff
changeset
|
140 compress_type}}} |
|
bb6cca57eb8b
Jim Ahlstrom sent a few corrections to my changes. (Thanks!)
Fred Drake <fdrake@acm.org>
parents:
14974
diff
changeset
|
141 Write the file named \var{filename} to the archive, giving it the |
|
bb6cca57eb8b
Jim Ahlstrom sent a few corrections to my changes. (Thanks!)
Fred Drake <fdrake@acm.org>
parents:
14974
diff
changeset
|
142 archive name \var{arcname} (by default, this will be the same as |
|
bb6cca57eb8b
Jim Ahlstrom sent a few corrections to my changes. (Thanks!)
Fred Drake <fdrake@acm.org>
parents:
14974
diff
changeset
|
143 \var{filename}). If given, \var{compress_type} overrides the value |
|
bb6cca57eb8b
Jim Ahlstrom sent a few corrections to my changes. (Thanks!)
Fred Drake <fdrake@acm.org>
parents:
14974
diff
changeset
|
144 given for the \var{compression} parameter to the constructor for |
|
bb6cca57eb8b
Jim Ahlstrom sent a few corrections to my changes. (Thanks!)
Fred Drake <fdrake@acm.org>
parents:
14974
diff
changeset
|
145 the new entry. The archive must be open with mode \code{'w'} or |
|
bb6cca57eb8b
Jim Ahlstrom sent a few corrections to my changes. (Thanks!)
Fred Drake <fdrake@acm.org>
parents:
14974
diff
changeset
|
146 \code{'a'}. |
|
14974
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
147 \end{methoddesc} |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
148 |
|
14990
bb6cca57eb8b
Jim Ahlstrom sent a few corrections to my changes. (Thanks!)
Fred Drake <fdrake@acm.org>
parents:
14974
diff
changeset
|
149 \begin{methoddesc}{writestr}{zinfo, bytes} |
|
bb6cca57eb8b
Jim Ahlstrom sent a few corrections to my changes. (Thanks!)
Fred Drake <fdrake@acm.org>
parents:
14974
diff
changeset
|
150 Write the string \var{bytes} to the archive; meta-information is |
|
bb6cca57eb8b
Jim Ahlstrom sent a few corrections to my changes. (Thanks!)
Fred Drake <fdrake@acm.org>
parents:
14974
diff
changeset
|
151 given as the \class{ZipInfo} instance \var{zinfo}. At least the |
|
bb6cca57eb8b
Jim Ahlstrom sent a few corrections to my changes. (Thanks!)
Fred Drake <fdrake@acm.org>
parents:
14974
diff
changeset
|
152 filename, date, and time must be given by \var{zinfo}. The archive |
|
bb6cca57eb8b
Jim Ahlstrom sent a few corrections to my changes. (Thanks!)
Fred Drake <fdrake@acm.org>
parents:
14974
diff
changeset
|
153 must be opened with mode \code{'w'} or \code{'a'}. |
| 12198 | 154 \end{methoddesc} |
| 155 | |
|
14974
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
156 |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
157 The following data attribute is also available: |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
158 |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
159 \begin{memberdesc}{debug} |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
160 The level of debug output to use. This may be set from \code{0} |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
161 (the default, no output) to \code{3} (the most output). Debugging |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
162 information is written to \code{sys.stdout}. |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
163 \end{memberdesc} |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
164 |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
165 |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
166 \subsection{PyZipFile Objects \label{pyzipfile-objects}} |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
167 |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
168 The \class{PyZipFile} constructor takes the same parameters as the |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
169 \class{ZipFile} constructor. Instances have one method in addition to |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
170 those of \class{ZipFile} objects. |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
171 |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
172 \begin{methoddesc}[PyZipFile]{writepy}{pathname\optional{, basename}} |
| 12198 | 173 Search for files \file{*.py} and add the corresponding file to the |
| 174 archive. The corresponding file is a \file{*.pyo} file if | |
| 175 available, else a \file{*.pyc} file, compiling if necessary. If the | |
| 176 pathname is a file, the filename must end with \file{.py}, and just | |
|
14974
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
177 the (corresponding \file{*.py[co]}) file is added at the top level |
| 12198 | 178 (no path information). If it is a directory, and the directory is |
|
14974
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
179 not a package directory, then all the files \file{*.py[co]} are |
| 12198 | 180 added at the top level. If the directory is a package directory, |
| 181 then all \file{*.py[oc]} are added under the package name as a file | |
| 182 path, and if any subdirectories are package directories, all of | |
| 183 these are added recursively. \var{basename} is intended for | |
| 184 internal use only. The \method{writepy()} method makes archives | |
| 185 with file names like this: | |
| 186 | |
| 187 \begin{verbatim} | |
| 188 string.pyc # Top level name | |
| 189 test/__init__.pyc # Package directory | |
| 190 test/testall.pyc # Module test.testall | |
| 191 test/bogus/__init__.pyc # Subpackage directory | |
| 192 test/bogus/myfile.pyc # Submodule test.bogus.myfile | |
| 193 \end{verbatim} | |
| 194 \end{methoddesc} | |
| 195 | |
|
14974
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
196 |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
197 \subsection{ZipInfo Objects \label{zipinfo-objects}} |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
198 |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
199 Instances of the \class{ZipInfo} class are returned by the |
|
14990
bb6cca57eb8b
Jim Ahlstrom sent a few corrections to my changes. (Thanks!)
Fred Drake <fdrake@acm.org>
parents:
14974
diff
changeset
|
200 \method{getinfo()} and \method{infolist()} methods of |
|
14974
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
201 \class{ZipFile} objects. Each object stores information about a |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
202 single member of the ZIP archive. |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
203 |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
204 Instances have the following attributes: |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
205 |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
206 \begin{memberdesc}[ZipInfo]{filename} |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
207 Name of the file in the archive. |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
208 \end{memberdesc} |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
209 |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
210 \begin{memberdesc}[ZipInfo]{date_time} |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
211 The time and date of the last modification to to the archive |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
212 member. This is a tuple of six values: |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
213 |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
214 \begin{tableii}{c|l}{code}{Index}{Value} |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
215 \lineii{0}{Year} |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
216 \lineii{1}{Month (one-based)} |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
217 \lineii{2}{Day of month (one-based)} |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
218 \lineii{3}{Hours (zero-based)} |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
219 \lineii{4}{Minutes (zero-based)} |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
220 \lineii{5}{Seconds (zero-based)} |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
221 \end{tableii} |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
222 \end{memberdesc} |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
223 |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
224 \begin{memberdesc}[ZipInfo]{compress_type} |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
225 Type of compression for the archive member. |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
226 \end{memberdesc} |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
227 |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
228 \begin{memberdesc}[ZipInfo]{comment} |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
229 Comment for the individual archive member. |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
230 \end{memberdesc} |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
231 |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
232 \begin{memberdesc}[ZipInfo]{extra} |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
233 Expansion field data. The |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
234 \citetitle[http://www.pkware.com/appnote.html]{PKZIP Application |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
235 Note} contains some comments on the internal structure of the data |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
236 contained in this string. |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
237 \end{memberdesc} |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
238 |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
239 \begin{memberdesc}[ZipInfo]{create_system} |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
240 System which created ZIP archive. |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
241 \end{memberdesc} |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
242 |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
243 \begin{memberdesc}[ZipInfo]{create_version} |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
244 PKZIP version which created ZIP archive. |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
245 \end{memberdesc} |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
246 |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
247 \begin{memberdesc}[ZipInfo]{extract_version} |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
248 PKZIP version needed to extract archive. |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
249 \end{memberdesc} |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
250 |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
251 \begin{memberdesc}[ZipInfo]{reserved} |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
252 Must be zero. |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
253 \end{memberdesc} |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
254 |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
255 \begin{memberdesc}[ZipInfo]{flag_bits} |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
256 ZIP flag bits. |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
257 \end{memberdesc} |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
258 |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
259 \begin{memberdesc}[ZipInfo]{volume} |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
260 Volume number of file header. |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
261 \end{memberdesc} |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
262 |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
263 \begin{memberdesc}[ZipInfo]{internal_attr} |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
264 Internal attributes. |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
265 \end{memberdesc} |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
266 |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
267 \begin{memberdesc}[ZipInfo]{external_attr} |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
268 External file attributes. |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
269 \end{memberdesc} |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
270 |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
271 \begin{memberdesc}[ZipInfo]{header_offset} |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
272 Byte offset to the file header. |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
273 \end{memberdesc} |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
274 |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
275 \begin{memberdesc}[ZipInfo]{file_offset} |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
276 Byte offset to the start of the file data. |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
277 \end{memberdesc} |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
278 |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
279 \begin{memberdesc}[ZipInfo]{CRC} |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
280 CRC-32 of the uncompressed file. |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
281 \end{memberdesc} |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
282 |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
283 \begin{memberdesc}[ZipInfo]{compress_size} |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
284 Size of the compressed data. |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
285 \end{memberdesc} |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
286 |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
287 \begin{memberdesc}[ZipInfo]{file_size} |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
288 Size of the uncompressed file. |
|
c7907379a6bd
Substantially revised documentation for the zipfile module, partially based
Fred Drake <fdrake@acm.org>
parents:
14934
diff
changeset
|
289 \end{memberdesc} |
