1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><title>Python: module olefile2</title>
</head><body bgcolor="#f0f0f8">
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading">
<tr bgcolor="#7799ee">
<td valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"> <br><big><big><strong>olefile2</strong></big></big> (version 0.40py2, 2014-10-01)</font></td
><td align=right valign=bottom
><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:./olefile2.py">.\olefile2.py</a></font></td></tr></table>
<p><tt>olefile2 (formerly OleFileIO_PL2) version 0.40py2 2014-10-01<br>
<br>
Module to read Microsoft OLE2 files (also called Structured Storage or<br>
Microsoft Compound Document File Format), such as Microsoft Office<br>
documents, Image Composer and FlashPix files, Outlook messages, ...<br>
<br>
IMPORTANT NOTE: olefile2 is an old version of olefile meant to be used<br>
as fallback for Python 2.5 and older. For Python 2.6, 2.7 and 3.x, please use<br>
olefile which is more up-to-date. The improvements in olefile might<br>
not always be backported to olefile2.<br>
<br>
Project website: <a href="http://www.decalage.info/python/olefileio">http://www.decalage.info/python/olefileio</a><br>
<br>
olefile2 is copyright (c) 2005-2014 Philippe Lagadec (<a href="http://www.decalage.info">http://www.decalage.info</a>)<br>
<br>
olefile2 is based on the <a href="#OleFileIO">OleFileIO</a> module from the PIL library v1.1.6<br>
See: <a href="http://www.pythonware.com/products/pil/index.htm">http://www.pythonware.com/products/pil/index.htm</a><br>
<br>
The Python Imaging Library (PIL) is<br>
Copyright (c) 1997-2005 by Secret Labs AB<br>
Copyright (c) 1995-2005 by Fredrik Lundh<br>
<br>
See source code and LICENSE.txt for information on usage and redistribution.</tt></p>
<p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#aa55cc">
<td colspan=3 valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Modules</strong></big></font></td></tr>
<tr><td bgcolor="#aa55cc"><tt> </tt></td><td> </td>
<td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top><a href="StringIO.html">StringIO</a><br>
<a href="array.html">array</a><br>
</td><td width="25%" valign=top><a href="datetime.html">datetime</a><br>
<a href="os.html">os</a><br>
</td><td width="25%" valign=top><a href="string.html">string</a><br>
<a href="struct.html">struct</a><br>
</td><td width="25%" valign=top><a href="sys.html">sys</a><br>
</td></tr></table></td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ee77aa">
<td colspan=3 valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Classes</strong></big></font></td></tr>
<tr><td bgcolor="#ee77aa"><tt> </tt></td><td> </td>
<td width="100%"><dl>
<dt><font face="helvetica, arial"><a href="olefile2.html#OleFileIO">OleFileIO</a>
</font></dt></dl>
<p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom> <br>
<font color="#000000" face="helvetica, arial"><a name="OleFileIO">class <strong>OleFileIO</strong></a></font></td></tr>
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
<td colspan=2><tt>OLE container object<br>
<br>
This class encapsulates the interface to an OLE 2 structured<br>
storage file. Use the {@link listdir} and {@link openstream} methods to<br>
access the contents of this file.<br>
<br>
Object names are given as a list of strings, one for each subentry<br>
level. The root entry should be omitted. For example, the following<br>
code extracts all image streams from a Microsoft Image Composer file:<br>
<br>
ole = <a href="#OleFileIO">OleFileIO</a>("fan.mic")<br>
<br>
for entry in ole.<a href="#OleFileIO-listdir">listdir</a>():<br>
if entry[1:2] == "Image":<br>
fin = ole.<a href="#OleFileIO-openstream">openstream</a>(entry)<br>
fout = <a href="#OleFileIO-open">open</a>(entry[0:1], "wb")<br>
while True:<br>
s = fin.read(8192)<br>
if not s:<br>
break<br>
fout.write(s)<br>
<br>
You can use the viewer application provided with the Python Imaging<br>
Library to view the resulting files (which happens to be standard<br>
TIFF files).<br> </tt></td></tr>
<tr><td> </td>
<td width="100%">Methods defined here:<br>
<dl><dt><a name="OleFileIO-__init__"><strong>__init__</strong></a>(self, filename<font color="#909090">=None</font>, raise_defects<font color="#909090">=40</font>)</dt><dd><tt>Constructor for <a href="#OleFileIO">OleFileIO</a> class.<br>
<br>
filename: file to open.<br>
raise_defects: minimal level for defects to be raised as exceptions.<br>
(use DEFECT_FATAL for a typical application, DEFECT_INCORRECT for a<br>
security-oriented application, see source code for details)</tt></dd></dl>
<dl><dt><a name="OleFileIO-close"><strong>close</strong></a>(self)</dt><dd><tt>close the OLE file, to release the file object</tt></dd></dl>
<dl><dt><a name="OleFileIO-dumpdirectory"><strong>dumpdirectory</strong></a>(self)</dt><dd><tt>Dump directory (for debugging only)</tt></dd></dl>
<dl><dt><a name="OleFileIO-dumpfat"><strong>dumpfat</strong></a>(self, fat, firstindex<font color="#909090">=0</font>)</dt><dd><tt>Displays a part of FAT in human-readable form for debugging purpose</tt></dd></dl>
<dl><dt><a name="OleFileIO-dumpsect"><strong>dumpsect</strong></a>(self, sector, firstindex<font color="#909090">=0</font>)</dt><dd><tt>Displays a sector in a human-readable form, for debugging purpose.</tt></dd></dl>
<dl><dt><a name="OleFileIO-exists"><strong>exists</strong></a>(self, filename)</dt><dd><tt>Test if given filename exists as a stream or a storage in the OLE<br>
container.<br>
<br>
filename: path of stream in storage tree. (see openstream for syntax)<br>
return: True if object exist, else False.</tt></dd></dl>
<dl><dt><a name="OleFileIO-get_metadata"><strong>get_metadata</strong></a>(self)</dt><dd><tt>Parse standard properties streams, return an OleMetadata object<br>
containing all the available metadata.<br>
(also stored in the metadata attribute of the <a href="#OleFileIO">OleFileIO</a> object)<br>
<br>
new in version 0.25</tt></dd></dl>
<dl><dt><a name="OleFileIO-get_rootentry_name"><strong>get_rootentry_name</strong></a>(self)</dt><dd><tt>Return root entry name. Should usually be 'Root Entry' or 'R' in most<br>
implementations.</tt></dd></dl>
<dl><dt><a name="OleFileIO-get_size"><strong>get_size</strong></a>(self, filename)</dt><dd><tt>Return size of a stream in the OLE container, in bytes.<br>
<br>
filename: path of stream in storage tree (see openstream for syntax)<br>
return: size in bytes (long integer)<br>
raise: IOError if file not found, TypeError if this is not a stream.</tt></dd></dl>
<dl><dt><a name="OleFileIO-get_type"><strong>get_type</strong></a>(self, filename)</dt><dd><tt>Test if given filename exists as a stream or a storage in the OLE<br>
container, and return its type.<br>
<br>
filename: path of stream in storage tree. (see openstream for syntax)<br>
return: False if object does not exist, its entry type (>0) otherwise:<br>
- STGTY_STREAM: a stream<br>
- STGTY_STORAGE: a storage<br>
- STGTY_ROOT: the root entry</tt></dd></dl>
<dl><dt><a name="OleFileIO-getctime"><strong>getctime</strong></a>(self, filename)</dt><dd><tt>Return creation time of a stream/storage.<br>
<br>
filename: path of stream/storage in storage tree. (see openstream for<br>
syntax)<br>
return: None if creation time is null, a python datetime object<br>
otherwise (UTC timezone)<br>
<br>
new in version 0.26</tt></dd></dl>
<dl><dt><a name="OleFileIO-getmtime"><strong>getmtime</strong></a>(self, filename)</dt><dd><tt>Return modification time of a stream/storage.<br>
<br>
filename: path of stream/storage in storage tree. (see openstream for<br>
syntax)<br>
return: None if modification time is null, a python datetime object<br>
otherwise (UTC timezone)<br>
<br>
new in version 0.26</tt></dd></dl>
<dl><dt><a name="OleFileIO-getproperties"><strong>getproperties</strong></a>(self, filename, convert_time<font color="#909090">=False</font>, no_conversion<font color="#909090">=None</font>)</dt><dd><tt>Return properties described in substream.<br>
<br>
filename: path of stream in storage tree (see openstream for syntax)<br>
convert_time: bool, if True timestamps will be converted to Python datetime<br>
no_conversion: None or list of int, timestamps not to be converted<br>
(for example total editing time is not a real timestamp)<br>
return: a dictionary of values indexed by id (integer)</tt></dd></dl>
<dl><dt><a name="OleFileIO-getsect"><strong>getsect</strong></a>(self, sect)</dt><dd><tt>Read given sector from file on disk.<br>
sect: sector index<br>
returns a string containing the sector data.</tt></dd></dl>
<dl><dt><a name="OleFileIO-listdir"><strong>listdir</strong></a>(self, streams<font color="#909090">=True</font>, storages<font color="#909090">=False</font>)</dt><dd><tt>Return a list of streams stored in this file<br>
<br>
streams: bool, include streams if True (True by default) - new in v0.26<br>
storages: bool, include storages if True (False by default) - new in v0.26<br>
(note: the root storage is never included)</tt></dd></dl>
<dl><dt><a name="OleFileIO-loaddirectory"><strong>loaddirectory</strong></a>(self, sect)</dt><dd><tt>Load the directory.<br>
sect: sector index of directory stream.</tt></dd></dl>
<dl><dt><a name="OleFileIO-loadfat"><strong>loadfat</strong></a>(self, header)</dt><dd><tt>Load the FAT table.</tt></dd></dl>
<dl><dt><a name="OleFileIO-loadfat_sect"><strong>loadfat_sect</strong></a>(self, sect)</dt><dd><tt>Adds the indexes of the given sector to the FAT<br>
sect: string containing the first FAT sector, or array of long integers<br>
return: index of last FAT sector.</tt></dd></dl>
<dl><dt><a name="OleFileIO-loadminifat"><strong>loadminifat</strong></a>(self)</dt><dd><tt>Load the MiniFAT table.</tt></dd></dl>
<dl><dt><a name="OleFileIO-open"><strong>open</strong></a>(self, filename)</dt><dd><tt>Open an OLE2 file.<br>
Reads the header, FAT and directory.<br>
<br>
filename: string-like or file-like object</tt></dd></dl>
<dl><dt><a name="OleFileIO-openstream"><strong>openstream</strong></a>(self, filename)</dt><dd><tt>Open a stream as a read-only file object (StringIO).<br>
<br>
filename: path of stream in storage tree (except root entry), either:<br>
- a string using Unix path syntax, for example:<br>
'storage_1/storage_1.2/stream'<br>
- a list of storage filenames, path to the desired stream/storage.<br>
Example: ['storage_1', 'storage_1.2', 'stream']<br>
return: file object (read-only)<br>
raise IOError if filename not found, or if this is not a stream.</tt></dd></dl>
<dl><dt><a name="OleFileIO-sect2array"><strong>sect2array</strong></a>(self, sect)</dt><dd><tt>convert a sector to an array of 32 bits unsigned integers,<br>
swapping bytes on big endian CPUs such as PowerPC (old Macs)</tt></dd></dl>
</td></tr></table></td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#eeaa77">
<td colspan=3 valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Functions</strong></big></font></td></tr>
<tr><td bgcolor="#eeaa77"><tt> </tt></td><td> </td>
<td width="100%"><dl><dt><a name="-isOleFile"><strong>isOleFile</strong></a>(filename)</dt><dd><tt>Test if file is an OLE container (according to its header).<br>
filename: file name or path (str, unicode)<br>
return: True if OLE, False otherwise.</tt></dd></dl>
</td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#55aa55">
<td colspan=3 valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Data</strong></big></font></td></tr>
<tr><td bgcolor="#55aa55"><tt> </tt></td><td> </td>
<td width="100%"><strong>DEFECT_FATAL</strong> = 40<br>
<strong>DEFECT_INCORRECT</strong> = 30<br>
<strong>DEFECT_POTENTIAL</strong> = 20<br>
<strong>DEFECT_UNSURE</strong> = 10<br>
<strong>STGTY_EMPTY</strong> = 0<br>
<strong>STGTY_LOCKBYTES</strong> = 3<br>
<strong>STGTY_PROPERTY</strong> = 4<br>
<strong>STGTY_ROOT</strong> = 5<br>
<strong>STGTY_STORAGE</strong> = 1<br>
<strong>STGTY_STREAM</strong> = 2<br>
<strong>__all__</strong> = ['OleFileIO', 'isOleFile', 'DEFECT_UNSURE', 'STGTY_STREAM', 'DEFECT_FATAL', 'STGTY_EMPTY', 'STGTY_LOCKBYTES', 'STGTY_STORAGE', 'STGTY_PROPERTY', 'DEFECT_INCORRECT', 'DEFECT_POTENTIAL', 'STGTY_ROOT']<br>
<strong>__author__</strong> = 'Philippe Lagadec'<br>
<strong>__date__</strong> = '2014-10-01'<br>
<strong>__version__</strong> = '0.40py2'</td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#7799ee">
<td colspan=3 valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Author</strong></big></font></td></tr>
<tr><td bgcolor="#7799ee"><tt> </tt></td><td> </td>
<td width="100%">Philippe Lagadec</td></tr></table>
</body></html>
|