Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> |
2 | <html> | |
3 | <head> | |
4 | <link rel="STYLESHEET" href="lib.css" type='text/css' /> | |
5 | <link rel="SHORTCUT ICON" href="../icons/pyfav.png" type="image/png" /> | |
6 | <link rel='start' href='../index.html' title='Python Documentation Index' /> | |
7 | <link rel="first" href="lib.html" title='Python Library Reference' /> | |
8 | <link rel='contents' href='contents.html' title="Contents" /> | |
9 | <link rel='index' href='genindex.html' title='Index' /> | |
10 | <link rel='last' href='about.html' title='About this document...' /> | |
11 | <link rel='help' href='about.html' title='About this document...' /> | |
12 | <link rel="next" href="module-tarfile.html" /> | |
13 | <link rel="prev" href="module-bz2.html" /> | |
14 | <link rel="parent" href="someos.html" /> | |
15 | <link rel="next" href="zipfile-objects.html" /> | |
16 | <meta name='aesop' content='information' /> | |
17 | <title>7.18 zipfile -- Work with ZIP archives</title> | |
18 | </head> | |
19 | <body> | |
20 | <DIV CLASS="navigation"> | |
21 | <div id='top-navigation-panel' xml:id='top-navigation-panel'> | |
22 | <table align="center" width="100%" cellpadding="0" cellspacing="2"> | |
23 | <tr> | |
24 | <td class='online-navigation'><a rel="prev" title="7.17.3 One-shot (de)compression" | |
25 | href="node408.html"><img src='../icons/previous.png' | |
26 | border='0' height='32' alt='Previous Page' width='32' /></A></td> | |
27 | <td class='online-navigation'><a rel="parent" title="7. Optional Operating System" | |
28 | href="someos.html"><img src='../icons/up.png' | |
29 | border='0' height='32' alt='Up One Level' width='32' /></A></td> | |
30 | <td class='online-navigation'><a rel="next" title="7.18.1 ZipFile Objects" | |
31 | href="zipfile-objects.html"><img src='../icons/next.png' | |
32 | border='0' height='32' alt='Next Page' width='32' /></A></td> | |
33 | <td align="center" width="100%">Python Library Reference</td> | |
34 | <td class='online-navigation'><a rel="contents" title="Table of Contents" | |
35 | href="contents.html"><img src='../icons/contents.png' | |
36 | border='0' height='32' alt='Contents' width='32' /></A></td> | |
37 | <td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png' | |
38 | border='0' height='32' alt='Module Index' width='32' /></a></td> | |
39 | <td class='online-navigation'><a rel="index" title="Index" | |
40 | href="genindex.html"><img src='../icons/index.png' | |
41 | border='0' height='32' alt='Index' width='32' /></A></td> | |
42 | </tr></table> | |
43 | <div class='online-navigation'> | |
44 | <b class="navlabel">Previous:</b> | |
45 | <a class="sectref" rel="prev" href="node408.html">7.17.3 One-shot (de)compression</A> | |
46 | <b class="navlabel">Up:</b> | |
47 | <a class="sectref" rel="parent" href="someos.html">7. Optional Operating System</A> | |
48 | <b class="navlabel">Next:</b> | |
49 | <a class="sectref" rel="next" href="zipfile-objects.html">7.18.1 ZipFile Objects</A> | |
50 | </div> | |
51 | <hr /></div> | |
52 | </DIV> | |
53 | <!--End of Navigation Panel--> | |
54 | ||
55 | <H1><A NAME="SECTION0091800000000000000000"> | |
56 | 7.18 <tt class="module">zipfile</tt> -- | |
57 | Work with ZIP archives</A> | |
58 | </H1> | |
59 | ||
60 | <P> | |
61 | <A NAME="module-zipfile"></A> | |
62 | ||
63 | <P> | |
64 | ||
65 | <span class="versionnote">New in version 1.6.</span> | |
66 | ||
67 | <P> | |
68 | The ZIP file format is a common archive and compression standard. | |
69 | This module provides tools to create, read, write, append, and list a | |
70 | ZIP file. Any advanced use of this module will require an | |
71 | understanding of the format, as defined in | |
72 | <em class="citetitle"><a | |
73 | href="http://www.pkware.com/appnote.html" | |
74 | title="PKZIP Application | |
75 | Note" | |
76 | >PKZIP Application | |
77 | Note</a></em>. | |
78 | ||
79 | <P> | |
80 | This module does not currently handle ZIP files which have appended | |
81 | comments, or multi-disk ZIP files. | |
82 | ||
83 | <P> | |
84 | The available attributes of this module are: | |
85 | ||
86 | <P> | |
87 | <dl><dt><b><span class="typelabel">exception</span> <tt id='l2h-2851' xml:id='l2h-2851' class="exception">error</tt></b></dt> | |
88 | <dd> | |
89 | The error raised for bad ZIP files. | |
90 | </dd></dl> | |
91 | ||
92 | <P> | |
93 | <dl><dt><b><span class="typelabel">class</span> <tt id='l2h-2852' xml:id='l2h-2852' class="class">ZipFile</tt></b> | |
94 | <dd> | |
95 | The class for reading and writing ZIP files. See | |
96 | ``<em class="citetitle" | |
97 | >ZipFile Objects</em>'' (section <A href="zipfile-objects.html#zipfile-objects">7.18.1</A>) for | |
98 | constructor details. | |
99 | </dl> | |
100 | ||
101 | <P> | |
102 | <dl><dt><b><span class="typelabel">class</span> <tt id='l2h-2853' xml:id='l2h-2853' class="class">PyZipFile</tt></b> | |
103 | <dd> | |
104 | Class for creating ZIP archives containing Python libraries. | |
105 | </dl> | |
106 | ||
107 | <P> | |
108 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
109 | <td><nobr><b><span class="typelabel">class</span> <tt id='l2h-2854' xml:id='l2h-2854' class="class">ZipInfo</tt></b>(</nobr></td> | |
110 | <td><var></var><big>[</big><var>filename</var><big>[</big><var>, date_time</var><big>]</big><var></var><big>]</big><var></var>)</td></tr></table></dt> | |
111 | <dd> | |
112 | Class used to represent information about a member of an archive. | |
113 | Instances of this class are returned by the <tt class="method">getinfo()</tt> and | |
114 | <tt class="method">infolist()</tt> methods of <tt class="class">ZipFile</tt> objects. Most users | |
115 | of the <tt class="module">zipfile</tt> module will not need to create these, but | |
116 | only use those created by this module. | |
117 | <var>filename</var> should be the full name of the archive member, and | |
118 | <var>date_time</var> should be a tuple containing six fields which | |
119 | describe the time of the last modification to the file; the fields | |
120 | are described in section <A href="zipinfo-objects.html#zipinfo-objects">7.18.3</A>, ``ZipInfo Objects.'' | |
121 | </dl> | |
122 | ||
123 | <P> | |
124 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
125 | <td><nobr><b><tt id='l2h-2855' xml:id='l2h-2855' class="function">is_zipfile</tt></b>(</nobr></td> | |
126 | <td><var>filename</var>)</td></tr></table></dt> | |
127 | <dd> | |
128 | Returns <code>True</code> if <var>filename</var> is a valid ZIP file based on its magic | |
129 | number, otherwise returns <code>False</code>. This module does not currently | |
130 | handle ZIP files which have appended comments. | |
131 | </dl> | |
132 | ||
133 | <P> | |
134 | <dl><dt><b><tt id='l2h-2856' xml:id='l2h-2856'>ZIP_STORED</tt></b></dt> | |
135 | <dd> | |
136 | The numeric constant for an uncompressed archive member. | |
137 | </dd></dl> | |
138 | ||
139 | <P> | |
140 | <dl><dt><b><tt id='l2h-2857' xml:id='l2h-2857'>ZIP_DEFLATED</tt></b></dt> | |
141 | <dd> | |
142 | The numeric constant for the usual ZIP compression method. This | |
143 | requires the zlib module. No other compression methods are | |
144 | currently supported. | |
145 | </dd></dl> | |
146 | ||
147 | <P> | |
148 | <div class="seealso"> | |
149 | <p class="heading">See Also:</p> | |
150 | ||
151 | <dl compact="compact" class="seetitle"> | |
152 | <dt><em class="citetitle"><a href="http://www.pkware.com/appnote.html" | |
153 | >PKZIP Application | |
154 | Note</a></em></dt> | |
155 | <dd>Documentation on the ZIP file format by Phil | |
156 | Katz, the creator of the format and algorithms used.</dd> | |
157 | </dl> | |
158 | ||
159 | <P> | |
160 | <dl compact="compact" class="seetitle"> | |
161 | <dt><em class="citetitle"><a href="http://www.info-zip.org/pub/infozip/" | |
162 | >Info-ZIP Home Page</a></em></dt> | |
163 | <dd> | |
164 | Information about the Info-ZIP project's ZIP archive | |
165 | programs and development libraries.</dd> | |
166 | </dl> | |
167 | </div> | |
168 | ||
169 | <P> | |
170 | ||
171 | <p><br /></p><hr class='online-navigation' /> | |
172 | <div class='online-navigation'> | |
173 | <!--Table of Child-Links--> | |
174 | <A NAME="CHILD_LINKS"><STRONG>Subsections</STRONG></a> | |
175 | ||
176 | <UL CLASS="ChildLinks"> | |
177 | <LI><A href="zipfile-objects.html">7.18.1 ZipFile Objects</a> | |
178 | <LI><A href="pyzipfile-objects.html">7.18.2 PyZipFile Objects</a> | |
179 | <LI><A href="zipinfo-objects.html">7.18.3 ZipInfo Objects</a> | |
180 | </ul> | |
181 | <!--End of Table of Child-Links--> | |
182 | </div> | |
183 | ||
184 | <DIV CLASS="navigation"> | |
185 | <div class='online-navigation'> | |
186 | <p></p><hr /> | |
187 | <table align="center" width="100%" cellpadding="0" cellspacing="2"> | |
188 | <tr> | |
189 | <td class='online-navigation'><a rel="prev" title="7.17.3 One-shot (de)compression" | |
190 | href="node408.html"><img src='../icons/previous.png' | |
191 | border='0' height='32' alt='Previous Page' width='32' /></A></td> | |
192 | <td class='online-navigation'><a rel="parent" title="7. Optional Operating System" | |
193 | href="someos.html"><img src='../icons/up.png' | |
194 | border='0' height='32' alt='Up One Level' width='32' /></A></td> | |
195 | <td class='online-navigation'><a rel="next" title="7.18.1 ZipFile Objects" | |
196 | href="zipfile-objects.html"><img src='../icons/next.png' | |
197 | border='0' height='32' alt='Next Page' width='32' /></A></td> | |
198 | <td align="center" width="100%">Python Library Reference</td> | |
199 | <td class='online-navigation'><a rel="contents" title="Table of Contents" | |
200 | href="contents.html"><img src='../icons/contents.png' | |
201 | border='0' height='32' alt='Contents' width='32' /></A></td> | |
202 | <td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png' | |
203 | border='0' height='32' alt='Module Index' width='32' /></a></td> | |
204 | <td class='online-navigation'><a rel="index" title="Index" | |
205 | href="genindex.html"><img src='../icons/index.png' | |
206 | border='0' height='32' alt='Index' width='32' /></A></td> | |
207 | </tr></table> | |
208 | <div class='online-navigation'> | |
209 | <b class="navlabel">Previous:</b> | |
210 | <a class="sectref" rel="prev" href="node408.html">7.17.3 One-shot (de)compression</A> | |
211 | <b class="navlabel">Up:</b> | |
212 | <a class="sectref" rel="parent" href="someos.html">7. Optional Operating System</A> | |
213 | <b class="navlabel">Next:</b> | |
214 | <a class="sectref" rel="next" href="zipfile-objects.html">7.18.1 ZipFile Objects</A> | |
215 | </div> | |
216 | </div> | |
217 | <hr /> | |
218 | <span class="release-info">Release 2.4.2, documentation updated on 28 September 2005.</span> | |
219 | </DIV> | |
220 | <!--End of Navigation Panel--> | |
221 | <ADDRESS> | |
222 | See <i><a href="about.html">About this document...</a></i> for information on suggesting changes. | |
223 | </ADDRESS> | |
224 | </BODY> | |
225 | </HTML> |