Easily convert your CALS, HTML, Formex4, Office Open XML (docx) tables from one format to another.
Overview
To convert the tables of a .docx document to CALS format, you can process as follow:
import os
import zipfile
from benker.converters.ooxml2cals import convert_ooxml2cals
# - Unzip the ``.docx`` in a temporary directory
src_zip = "/path/to/demo.docx"
tmp_dir = "/path/to/tmp/dir/"
with zipfile.ZipFile(src_zip) as zf:
zf.extractall(tmp_dir)
# - Source paths
src_xml = os.path.join(tmp_dir, "word/document.xml")
styles_xml = os.path.join(tmp_dir, "word/styles.xml")
# - Destination path
dst_xml = "/path/to/demo.xml"
# - Create some options and convert tables
options = {
'encoding': 'utf-8',
'styles_path': styles_xml,
'width_unit': "mm",
'table_in_tgroup': True,
}
convert_ooxml2cals(src_xml, dst_xml, **options)
Installation
To install this library, you can create and activate a virtualenv, and run:
pip install benker
Requirements
This library uses lxml library and is tested with the versions 3.8 and 4.*x*.
The following table shows the compatibility between different combinations of Python and lxml versions:
Py ╲ lxml |
3.8 |
4.0 |
4.1 |
4.2 |
4.3 |
4.4 |
4.5 |
4.6 |
|---|---|---|---|---|---|---|---|---|
2.7 |
✔️ |
✔️ |
✔️ |
✔️ |
✔️ |
✔️ |
✔️ |
✔️ |
3.4 |
✔️! |
✔️! |
✔️! |
✔️! |
✔️! |
✖️ |
✖️ |
✖️ |
3.5 |
✔️ |
✔️ |
✔️ |
✔️ |
✔️ |
✔️ |
✔️ |
✔️ |
3.6 |
✔️ |
✔️ |
✔️ |
✔️ |
✔️ |
✔️ |
✔️ |
✔️ |
3.7 |
✖️ |
✖️ |
✔️ |
✔️ |
✔️ |
✔️ |
✔️ |
✔️ |
3.8 |
✖️ |
✖️ |
✖️ |
✖️ |
✔️ |
✔️ |
✔️ |
✔️ |
3.9 |
✖️ |
✖️ |
✖️ |
✖️ |
✔️ |
✔️ |
✔️ |
✔️ |
✔️ lxml is available for this version and unit tests succeed.
! installation succeed using “attrs < 21.1”.
✖️ lxml is not available for this version of Python.
Usage in your library/application
You can use this library in your own library/application.
To do so, add this library in your setup.py in your project requirements:
setup(
name="YourApp",
install_requires=['benker'],
...
)
To install the dependencies, activate your virtualenv and run:
pip install -e .
And enjoy!
Licence
This library is distributed according to the MIT licence.
Users have legal right to download, modify, or distribute the library.
Metadata
Release files for Benker 0.5.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| Benker-0.5.4.tar.gz | 889.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| Benker-0.5.4-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details |
Total release size: 1.3 MB
Release files / Benker-0.5.4.tar.gz
| Download URL | Benker-0.5.4.tar.gz |
|---|---|
| Size | 889.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1f9b96473926ab4d6e56743af4732134127b10be345616bc5480d23526c6a979
|
|
BLAKE2b-256 checksum How to use checksums |
250f89956345b3a950b80bf3bb978981bb165c7f50f8a00fc7168cff6e0c282a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.5.0.1 requests/2.23.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.6.8
|
Release files / Benker-0.5.4-py2.py3-none-any.whl
| Download URL | Benker-0.5.4-py2.py3-none-any.whl |
|---|---|
| Size | 446.5 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
44803f6742dc64068c3820a8978d51e506d37698ec12a14b9f07f07e6137ebcf
|
|
BLAKE2b-256 checksum How to use checksums |
b4288c2c81369cc2947995fdfc5dab992ffec22757cce1ab2e80be8bcebb6a45
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.5.0.1 requests/2.23.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.6.8
|