olefile2 (version 0.40py2, 2014-10-01) | index .\olefile2.py

`olefile2 (formerly OleFileIO_PL2) version 0.40py2 2014-10-01
Module to read Microsoft OLE2 files (also called Structured Storage or
Microsoft Compound Document File Format), such as Microsoft Office
documents, Image Composer and FlashPix files, Outlook messages, ...
IMPORTANT NOTE: olefile2 is an old version of olefile meant to be used
as fallback for Python 2.5 and older. For Python 2.6, 2.7 and 3.x, please use
olefile which is more up-to-date. The improvements in olefile might
not always be backported to olefile2.
Project website: http://www.decalage.info/python/olefileio
olefile2 is copyright (c) 2005-2014 Philippe Lagadec (http://www.decalage.info)
olefile2 is based on the OleFileIO module from the PIL library v1.1.6
See: http://www.pythonware.com/products/pil/index.htm
The Python Imaging Library (PIL) is
Copyright (c) 1997-2005 by Secret Labs AB
Copyright (c) 1995-2005 by Fredrik Lundh
See source code and LICENSE.txt for information on usage and redistribution.`

Modules
`` |  |
StringIO array | datetime os | string struct | sys

Classes
`` |  | OleFileIO
class OleFileIO
`` | `OLE container object This class encapsulates the interface to an OLE 2 structured storage file. Use the {@link listdir} and {@link openstream} methods to access the contents of this file. Object names are given as a list of strings, one for each subentry level. The root entry should be omitted. For example, the following code extracts all image streams from a Microsoft Image Composer file: ole = OleFileIO("fan.mic") for entry in ole.listdir(): if entry[1:2] == "Image": fin = ole.openstream(entry) fout = open(entry[0:1], "wb") while True: s = fin.read(8192) if not s: break fout.write(s) You can use the viewer application provided with the Python Imaging Library to view the resulting files (which happens to be standard TIFF files).`
| Methods defined here: __init__(self, filename=None, raise_defects=40) `Constructor for OleFileIO class. filename: file to open. raise_defects: minimal level for defects to be raised as exceptions. (use DEFECT_FATAL for a typical application, DEFECT_INCORRECT for a security-oriented application, see source code for details)` close(self) `close the OLE file, to release the file object` dumpdirectory(self) `Dump directory (for debugging only)` dumpfat(self, fat, firstindex=0) `Displays a part of FAT in human-readable form for debugging purpose` dumpsect(self, sector, firstindex=0) `Displays a sector in a human-readable form, for debugging purpose.` exists(self, filename) `Test if given filename exists as a stream or a storage in the OLE container. filename: path of stream in storage tree. (see openstream for syntax) return: True if object exist, else False.` get_metadata(self) `Parse standard properties streams, return an OleMetadata object containing all the available metadata. (also stored in the metadata attribute of the OleFileIO object) new in version 0.25` get_rootentry_name(self) `Return root entry name. Should usually be 'Root Entry' or 'R' in most implementations.` get_size(self, filename) `Return size of a stream in the OLE container, in bytes. filename: path of stream in storage tree (see openstream for syntax) return: size in bytes (long integer) raise: IOError if file not found, TypeError if this is not a stream.` get_type(self, filename) `Test if given filename exists as a stream or a storage in the OLE container, and return its type. filename: path of stream in storage tree. (see openstream for syntax) return: False if object does not exist, its entry type (>0) otherwise: - STGTY_STREAM: a stream - STGTY_STORAGE: a storage - STGTY_ROOT: the root entry` getctime(self, filename) `Return creation time of a stream/storage. filename: path of stream/storage in storage tree. (see openstream for syntax) return: None if creation time is null, a python datetime object otherwise (UTC timezone) new in version 0.26` getmtime(self, filename) `Return modification time of a stream/storage. filename: path of stream/storage in storage tree. (see openstream for syntax) return: None if modification time is null, a python datetime object otherwise (UTC timezone) new in version 0.26` getproperties(self, filename, convert_time=False, no_conversion=None) `Return properties described in substream. filename: path of stream in storage tree (see openstream for syntax) convert_time: bool, if True timestamps will be converted to Python datetime no_conversion: None or list of int, timestamps not to be converted (for example total editing time is not a real timestamp) return: a dictionary of values indexed by id (integer)` getsect(self, sect) `Read given sector from file on disk. sect: sector index returns a string containing the sector data.` listdir(self, streams=True, storages=False) `Return a list of streams stored in this file streams: bool, include streams if True (True by default) - new in v0.26 storages: bool, include storages if True (False by default) - new in v0.26 (note: the root storage is never included)` loaddirectory(self, sect) `Load the directory. sect: sector index of directory stream.` loadfat(self, header) `Load the FAT table.` loadfat_sect(self, sect) `Adds the indexes of the given sector to the FAT sect: string containing the first FAT sector, or array of long integers return: index of last FAT sector.` loadminifat(self) `Load the MiniFAT table.` open(self, filename) `Open an OLE2 file. Reads the header, FAT and directory. filename: string-like or file-like object` openstream(self, filename) `Open a stream as a read-only file object (StringIO). filename: path of stream in storage tree (except root entry), either: - a string using Unix path syntax, for example: 'storage_1/storage_1.2/stream' - a list of storage filenames, path to the desired stream/storage. Example: ['storage_1', 'storage_1.2', 'stream'] return: file object (read-only) raise IOError if filename not found, or if this is not a stream.` sect2array(self, sect) `convert a sector to an array of 32 bits unsigned integers, swapping bytes on big endian CPUs such as PowerPC (old Macs)`

Functions
`` |  | isOleFile(filename) `Test if file is an OLE container (according to its header). filename: file name or path (str, unicode) return: True if OLE, False otherwise.`

Data
`` |  | DEFECT_FATAL = 40 DEFECT_INCORRECT = 30 DEFECT_POTENTIAL = 20 DEFECT_UNSURE = 10 STGTY_EMPTY = 0 STGTY_LOCKBYTES = 3 STGTY_PROPERTY = 4 STGTY_ROOT = 5 STGTY_STORAGE = 1 STGTY_STREAM = 2 __all__ = ['OleFileIO', 'isOleFile', 'DEFECT_UNSURE', 'STGTY_STREAM', 'DEFECT_FATAL', 'STGTY_EMPTY', 'STGTY_LOCKBYTES', 'STGTY_STORAGE', 'STGTY_PROPERTY', 'DEFECT_INCORRECT', 'DEFECT_POTENTIAL', 'STGTY_ROOT'] __author__ = 'Philippe Lagadec' __date__ = '2014-10-01' __version__ = '0.40py2'

Author
`` |  | Philippe Lagadec