Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/xrmx/pylokit
Python CFFI wrapper for LibreOfficeKit
https://github.com/xrmx/pylokit
Last synced: 23 days ago
JSON representation
Python CFFI wrapper for LibreOfficeKit
- Host: GitHub
- URL: https://github.com/xrmx/pylokit
- Owner: xrmx
- License: mpl-2.0
- Created: 2014-07-20T09:28:26.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2020-02-24T17:25:43.000Z (over 4 years ago)
- Last Synced: 2024-10-18T10:12:22.863Z (about 1 month ago)
- Language: Python
- Size: 22.5 KB
- Stars: 54
- Watchers: 8
- Forks: 6
- Open Issues: 6
-
Metadata Files:
- Readme: README.rst
- License: LICENSE
Awesome Lists containing this project
README
pylokit
=======A python CFFI wrapper for LibreOfficeKit. Tested in cpython2,
cpython3, and pypy. LibreOfficeKit currently works only on Linux systems.Requirements
------------An installation of LibreOffice >= 4.3.0 is required on the same machine.
If you are using cpython you need *libffi-dev* in order to compile CFFI.
Installation
------------You are encouraged to install pylokit on a python *virtualenv*.
.. code:: bash
pip install pylokit
Examples
--------A basic conversion from a rtf file to a doc:
.. code:: python
from pylokit import Office
import oslo_path = "/path/to/libreoffice/program/dir"
with Office(lo_path) as lo:
with lo.documentLoad("myfile.rtf") as doc:
doc.saveAs("myfile.doc")os._exit(0)
Same conversion passing an explicit format and filter options:
.. code:: python
from pylokit import Office
import oslo_path = "/path/to/libreoffice/program/dir"
with Office(lo_path) as lo:
with lo.documentLoad("myfile.rtf") as doc:
doc.saveAs("myfile.doc", fmt="docx", options="skipImages")os._exit(0)
The usage of a context manager is needed to properly handle LibreOfficeKit
file locking.
The use of _exit() instead of default exit() is required because in some
circumstances LibreOffice segfaults on process exit.Acknowledgements
----------------Project inspired by Olly Betts' `lloconv `_.