Python bindings for libcdr
Intro
Simple Python bindings for the libcdr. The binding chain is:
Python (CDRParser) → Cython (.pyx) → C++ (parser.cxx) → libcdr / librevenge
Installation
First, the libcdr newer than v0.1.8 must be compiled.
E.g. on Debian:
apt-get install automake cmake libtool libboost-all-dev libicu-dev liblcms2-dev librevenge-dev libcppunit-dev zlib1g-dev
git clone https://git.libreoffice.org/libcdr
cd libcdr
./autogen.sh
./configure
make && sudo make install
Then: pip install git+https://github.com/mpds-io/pylibcdr
The build steps (orchestrated automatically):
- CMake configures using
pylibcdr/CMakeLists.txt. - CMake invokes Cython to transpile
libcdr_interface.pyxintolibcdr_interface.cpp(viaadd_custom_command). - CMake compiles the generated
.cppandcore/parser.cxxinto the Python extensionlibcdr_interface(viaPython_add_library), linking againstlibcdrandlibrevenge.
If CMake fails, delete any _skbuild/ or build/ temp directories before retrying.
Usage
import sys
from pylibcdr import CDRParser
parser = CDRParser(sys.argv[1])
print(parser.xml) # raw XHTML/SVG string
print(parser.dict) # parsed as a nested dict
Architecture
| File | Role |
|---|---|
pylibcdr/__init__.py |
CDRParser class; converts XML string to dict via dictify() |
pylibcdr/libcdr_interface.pyx |
Cython bridge; calls svg(char*) from C++, raises CDRException on error strings |
pylibcdr/core/parser.cxx |
C++ core; uses libcdr/librevenge to parse CDR files, returns XHTML wrapping SVG pages |
pylibcdr/core/parser.h |
Header declaring std::string svg(char* file) |
pylibcdr/CMakeLists.txt |
CMake build: Cython transpilation + Python_add_library for the extension |
pylibcdr/cmake/ |
Custom Find*.cmake modules for libcdr and librevenge |
pyproject.toml |
Project metadata and scikit-build-core configuration |
The C++ svg() function returns an error string prefixed with "ERROR" on failure; the Cython layer detects this and raises CDRException.
The output of svg() is XHTML wrapping one or more SVG documents (one per page). CDRParser.xml exposes this raw string; CDRParser.dict parses it with xml.etree.ElementTree into a nested dict where repeated child tags become lists.
License
Inherited from the libcdr (MPL 2.0).
Metadata
Release files for pylibcdr 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pylibcdr-0.1.1.tar.gz | 4.8 kB | Without provenance | Details for pylibcdr-0.1.1.tar.gz |
Release files / pylibcdr-0.1.1.tar.gz
| Download URL | pylibcdr-0.1.1.tar.gz |
|---|---|
| Size | 4.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9b964f4497477bb867c12f03d44f50b10b6f49e278c3780c891a68a38519faba
|
|
BLAKE2b-256 checksum How to use checksums |
8fdc530ed53b44bd159f9480670b8837c31040c670e1be324e281f2dea015cee
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.8.10
|
Security for pylibcdr 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.