-
Notifications
You must be signed in to change notification settings - Fork 19
Python development
libolecf comes with Python-bindings named pyolecf.
Below are examples how use pyolecf. They assume you have a working version of pyolecf on your system. To build pyolecf see Building.
To be able to use pyolecf in your Python scripts add the following import:
import pyolecf
The get_version() module function can be used to retrieve the version of the pyolecf.
pyolecf.get_version()
This will return a textual string (Unicode) that contains the libolecf version. Since pyolecf is a wrapper around libolecf it does not have a separate version.
olecf_file = pyolecf.file()
olecf_file.open("Test.doc")
...
olecf_file.close()
The explicit call to olecf_file.close() is not required. Close only must be called once all operations on the file have been completed.
file_object = open("Test.doc", "rb")
olecf_file = pyolecf.file()
olecf_file.open_file_object(file_object)
...
olecf_file.close()
The explicit call to olecf_file.close() is not required. Close only must be called once all operations on the file have been completed and will not close the file-like object itself.
import pyolecf
help(pyolecf)
help(pyolecf.file)