pyodr 0.0.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pyodr-0.0.1/.github/config/macos-13/conan/profiles/default +8 -0
- pyodr-0.0.1/.github/config/ubuntu-22.04/conan/profiles/default +11 -0
- pyodr-0.0.1/.github/config/windows-2022/conan/profiles/default +8 -0
- pyodr-0.0.1/.github/workflows/format.yaml +20 -0
- pyodr-0.0.1/.github/workflows/pip.yaml +30 -0
- pyodr-0.0.1/.github/workflows/wheels.yaml +67 -0
- pyodr-0.0.1/.gitignore +8 -0
- pyodr-0.0.1/CMakeLists.txt +11 -0
- pyodr-0.0.1/PKG-INFO +12 -0
- pyodr-0.0.1/README.md +3 -0
- pyodr-0.0.1/conanfile.txt +7 -0
- pyodr-0.0.1/pyproject.toml +11 -0
- pyodr-0.0.1/setup.cfg +4 -0
- pyodr-0.0.1/setup.py +46 -0
- pyodr-0.0.1/src/pyodr/CMakeLists.txt +7 -0
- pyodr-0.0.1/src/pyodr/__init__.py +0 -0
- pyodr-0.0.1/src/pyodr/cli.py +40 -0
- pyodr-0.0.1/src/pyodr/core.cpp +289 -0
- pyodr-0.0.1/src/pyodr.egg-info/PKG-INFO +12 -0
- pyodr-0.0.1/src/pyodr.egg-info/SOURCES.txt +23 -0
- pyodr-0.0.1/src/pyodr.egg-info/dependency_links.txt +1 -0
- pyodr-0.0.1/src/pyodr.egg-info/entry_points.txt +2 -0
- pyodr-0.0.1/src/pyodr.egg-info/requires.txt +6 -0
- pyodr-0.0.1/src/pyodr.egg-info/top_level.txt +1 -0
- pyodr-0.0.1/tests/test_foobar.py +5 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
name: format
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
pull_request:
|
|
5
|
+
push:
|
|
6
|
+
branches:
|
|
7
|
+
- main
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
pre-commit:
|
|
11
|
+
name: black
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
steps:
|
|
14
|
+
- uses: actions/checkout@v4
|
|
15
|
+
- uses: actions/setup-python@v5
|
|
16
|
+
with:
|
|
17
|
+
python-version: "3.x"
|
|
18
|
+
- run: pip install black
|
|
19
|
+
- run: black src/pyodr
|
|
20
|
+
- run: git diff --exit-code
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
name: pip
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
pull_request:
|
|
5
|
+
push:
|
|
6
|
+
branches:
|
|
7
|
+
- main
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
build:
|
|
11
|
+
strategy:
|
|
12
|
+
fail-fast: false
|
|
13
|
+
matrix:
|
|
14
|
+
os: [ubuntu-22.04, macos-13, windows-2022]
|
|
15
|
+
python-version: ["3.7", "3.11"]
|
|
16
|
+
runs-on: ${{ matrix.os }}
|
|
17
|
+
steps:
|
|
18
|
+
- uses: actions/checkout@v4
|
|
19
|
+
- uses: actions/setup-python@v5
|
|
20
|
+
with:
|
|
21
|
+
python-version: ${{ matrix.python-version }}
|
|
22
|
+
- name: Add requirements
|
|
23
|
+
run: python -m pip install --upgrade pip wheel setuptools conan
|
|
24
|
+
- name: Install conan config
|
|
25
|
+
run: conan config install .github/config/${{ matrix.os }}/conan
|
|
26
|
+
- name: Build and install
|
|
27
|
+
run: pip install --verbose .[test]
|
|
28
|
+
# TODO
|
|
29
|
+
#- name: Test
|
|
30
|
+
# run: python -m pytest
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
name: wheels
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
pull_request:
|
|
5
|
+
push:
|
|
6
|
+
branches:
|
|
7
|
+
- main
|
|
8
|
+
release:
|
|
9
|
+
types:
|
|
10
|
+
- published
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
build_sdist:
|
|
14
|
+
name: Build SDist
|
|
15
|
+
runs-on: ubuntu-24.04
|
|
16
|
+
steps:
|
|
17
|
+
- uses: actions/checkout@v4
|
|
18
|
+
- name: Build SDist
|
|
19
|
+
run: pipx run build --sdist
|
|
20
|
+
- name: Check metadata
|
|
21
|
+
run: pipx run twine check dist/*
|
|
22
|
+
- uses: actions/upload-artifact@v4
|
|
23
|
+
with:
|
|
24
|
+
name: cibw-sdist
|
|
25
|
+
path: dist/*.tar.gz
|
|
26
|
+
|
|
27
|
+
build_wheels:
|
|
28
|
+
name: Wheels on ${{ matrix.os }}
|
|
29
|
+
runs-on: ${{ matrix.os }}
|
|
30
|
+
strategy:
|
|
31
|
+
fail-fast: false
|
|
32
|
+
matrix:
|
|
33
|
+
os: [ubuntu-22.04, macos-13]
|
|
34
|
+
steps:
|
|
35
|
+
- uses: actions/checkout@v4
|
|
36
|
+
- uses: pypa/cibuildwheel@v2.17
|
|
37
|
+
env:
|
|
38
|
+
MACOSX_DEPLOYMENT_TARGET: 10.15
|
|
39
|
+
CIBW_ARCHS_MACOS: auto universal2
|
|
40
|
+
CIBW_SKIP: "*-manylinux_i686 *-musllinux_*"
|
|
41
|
+
CIBW_BUILD_VERBOSITY: 1
|
|
42
|
+
- name: Verify clean directory
|
|
43
|
+
run: git diff --exit-code
|
|
44
|
+
shell: bash
|
|
45
|
+
- name: Upload wheels
|
|
46
|
+
uses: actions/upload-artifact@v4
|
|
47
|
+
with:
|
|
48
|
+
name: cibw-wheels-${{ matrix.os }}
|
|
49
|
+
path: wheelhouse/*.whl
|
|
50
|
+
|
|
51
|
+
upload_all:
|
|
52
|
+
name: Upload if release
|
|
53
|
+
needs: [build_wheels, build_sdist]
|
|
54
|
+
runs-on: ubuntu-24.04
|
|
55
|
+
if: github.event_name == 'release' && github.event.action == 'published'
|
|
56
|
+
steps:
|
|
57
|
+
- uses: actions/setup-python@v5
|
|
58
|
+
with:
|
|
59
|
+
python-version: "3.x"
|
|
60
|
+
- uses: actions/download-artifact@v4
|
|
61
|
+
with:
|
|
62
|
+
pattern: cibw-*
|
|
63
|
+
path: dist
|
|
64
|
+
merge-multiple: true
|
|
65
|
+
- uses: pypa/gh-action-pypi-publish@release/v1
|
|
66
|
+
with:
|
|
67
|
+
password: ${{ secrets.PYPI_TOKEN }}
|
pyodr-0.0.1/.gitignore
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
cmake_minimum_required(VERSION 3.18.1)
|
|
2
|
+
project(pyodr CXX)
|
|
3
|
+
|
|
4
|
+
set(CMAKE_CXX_STANDARD 20)
|
|
5
|
+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
6
|
+
set(CMAKE_CXX_EXTENSIONS OFF)
|
|
7
|
+
|
|
8
|
+
find_package(odrcore REQUIRED)
|
|
9
|
+
find_package(pybind11 REQUIRED)
|
|
10
|
+
|
|
11
|
+
add_subdirectory(src/pyodr)
|
pyodr-0.0.1/PKG-INFO
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: pyodr
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: It's Android's first OpenOffice Document Reader for Python!
|
|
5
|
+
Author: Andreas Stefl
|
|
6
|
+
Author-email: stefl.andreas@gmail.com
|
|
7
|
+
Requires-Python: >=3.7
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
Provides-Extra: dev
|
|
10
|
+
Requires-Dist: black; extra == "dev"
|
|
11
|
+
Provides-Extra: test
|
|
12
|
+
Requires-Dist: pytest>=6.0; extra == "test"
|
pyodr-0.0.1/README.md
ADDED
pyodr-0.0.1/setup.cfg
ADDED
pyodr-0.0.1/setup.py
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
from skbuild_conan import setup
|
|
2
|
+
from setuptools import find_packages
|
|
3
|
+
import subprocess
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
conan_odr_remote = "https://artifactory.opendocument.app/artifactory/api/conan/conan"
|
|
8
|
+
result = subprocess.run(["conan", "remote", "list"], check=True, capture_output=True, text=True)
|
|
9
|
+
if conan_odr_remote not in result.stdout:
|
|
10
|
+
print(f"Adding Conan remote {conan_odr_remote}")
|
|
11
|
+
subprocess.run(
|
|
12
|
+
[
|
|
13
|
+
"conan",
|
|
14
|
+
"remote",
|
|
15
|
+
"add",
|
|
16
|
+
"odr",
|
|
17
|
+
conan_odr_remote,
|
|
18
|
+
],
|
|
19
|
+
check=True,
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
this_directory = Path(__file__).parent
|
|
23
|
+
long_description = (this_directory / "README.md").read_text()
|
|
24
|
+
|
|
25
|
+
setup(
|
|
26
|
+
name="pyodr",
|
|
27
|
+
version="0.0.1",
|
|
28
|
+
author="Andreas Stefl",
|
|
29
|
+
author_email="stefl.andreas@gmail.com",
|
|
30
|
+
description="It's Android's first OpenOffice Document Reader for Python!",
|
|
31
|
+
long_description="",
|
|
32
|
+
long_description_content_type="text/markdown",
|
|
33
|
+
python_requires=">=3.7",
|
|
34
|
+
cmake_minimum_required_version="3.12",
|
|
35
|
+
packages=find_packages("src"),
|
|
36
|
+
package_dir={"": "src"},
|
|
37
|
+
install_requires=[],
|
|
38
|
+
extras_require={
|
|
39
|
+
"dev": ["black"],
|
|
40
|
+
"test": ["pytest>=6.0"],
|
|
41
|
+
},
|
|
42
|
+
conan_profile_settings={"compiler.cppstd": "20"},
|
|
43
|
+
entry_points = {
|
|
44
|
+
"console_scripts": ["pyodr=pyodr.cli:main"],
|
|
45
|
+
},
|
|
46
|
+
)
|
|
File without changes
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import sys
|
|
2
|
+
import argparse
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
from typing import Sequence
|
|
5
|
+
import tempfile
|
|
6
|
+
import webbrowser
|
|
7
|
+
|
|
8
|
+
import pyodr.core as core
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def main(args: Sequence[str] | None = None) -> int:
|
|
12
|
+
parser = argparse.ArgumentParser(description="OpenDocument Reader")
|
|
13
|
+
parser.add_argument("file", type=Path, help="The file to open")
|
|
14
|
+
args = parser.parse_args(args)
|
|
15
|
+
|
|
16
|
+
html_config = core.HtmlConfig()
|
|
17
|
+
|
|
18
|
+
print(f"Opening file: {str(args.file)}")
|
|
19
|
+
file = core.open(str(args.file))
|
|
20
|
+
if not file.is_valid():
|
|
21
|
+
print(f"Unable to open")
|
|
22
|
+
return 1
|
|
23
|
+
print(f"Type detected as {file.file_type()}")
|
|
24
|
+
|
|
25
|
+
tmp_dir = Path(tempfile.mkdtemp(prefix="pyodr-", suffix=".tmp"))
|
|
26
|
+
print(f"Translating html to {str(tmp_dir)}")
|
|
27
|
+
html = core.html.translate(file, str(tmp_dir), html_config)
|
|
28
|
+
print("Done")
|
|
29
|
+
|
|
30
|
+
for page in html.pages():
|
|
31
|
+
url = f"file://{str(page.path)}"
|
|
32
|
+
print(f"Opening {page.name} via {url}")
|
|
33
|
+
webbrowser.open(url)
|
|
34
|
+
|
|
35
|
+
return 0
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
if __name__ == "__main__":
|
|
39
|
+
error = main()
|
|
40
|
+
sys.exit(error)
|
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
#include <pybind11/pybind11.h>
|
|
2
|
+
#include <pybind11/stl.h>
|
|
3
|
+
|
|
4
|
+
#include <odr/document.hpp>
|
|
5
|
+
#include <odr/document_element.hpp>
|
|
6
|
+
#include <odr/file.hpp>
|
|
7
|
+
#include <odr/filesystem.hpp>
|
|
8
|
+
#include <odr/html.hpp>
|
|
9
|
+
#include <odr/open_document_reader.hpp>
|
|
10
|
+
|
|
11
|
+
namespace py = pybind11;
|
|
12
|
+
|
|
13
|
+
PYBIND11_MODULE(core, m) {
|
|
14
|
+
{
|
|
15
|
+
m.attr("__version__") = odr::OpenDocumentReader::version();
|
|
16
|
+
m.attr("version") = odr::OpenDocumentReader::version();
|
|
17
|
+
m.attr("commit") = odr::OpenDocumentReader::commit();
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
{
|
|
21
|
+
py::enum_<odr::FileType>(m, "FileType")
|
|
22
|
+
.value("unknown", odr::FileType::unknown)
|
|
23
|
+
.value("opendocument_text", odr::FileType::opendocument_text)
|
|
24
|
+
.value("opendocument_presentation",
|
|
25
|
+
odr::FileType::opendocument_presentation)
|
|
26
|
+
.value("opendocument_spreadsheet",
|
|
27
|
+
odr::FileType::opendocument_spreadsheet)
|
|
28
|
+
.value("opendocument_graphics", odr::FileType::opendocument_graphics)
|
|
29
|
+
.value("office_open_xml_document",
|
|
30
|
+
odr::FileType::office_open_xml_document)
|
|
31
|
+
.value("office_open_xml_presentation",
|
|
32
|
+
odr::FileType::office_open_xml_presentation)
|
|
33
|
+
.value("office_open_xml_workbook",
|
|
34
|
+
odr::FileType::office_open_xml_workbook)
|
|
35
|
+
.value("office_open_xml_encrypted",
|
|
36
|
+
odr::FileType::office_open_xml_encrypted)
|
|
37
|
+
.value("legacy_word_document", odr::FileType::legacy_word_document)
|
|
38
|
+
.value("legacy_powerpoint_presentation",
|
|
39
|
+
odr::FileType::legacy_powerpoint_presentation)
|
|
40
|
+
.value("legacy_excel_worksheets",
|
|
41
|
+
odr::FileType::legacy_excel_worksheets)
|
|
42
|
+
.value("word_perfect", odr::FileType::word_perfect)
|
|
43
|
+
.value("rich_text_format", odr::FileType::rich_text_format)
|
|
44
|
+
.value("portable_document_format",
|
|
45
|
+
odr::FileType::portable_document_format)
|
|
46
|
+
.value("text_file", odr::FileType::text_file)
|
|
47
|
+
.value("comma_separated_values", odr::FileType::comma_separated_values)
|
|
48
|
+
.value("javascript_object_notation",
|
|
49
|
+
odr::FileType::javascript_object_notation)
|
|
50
|
+
.value("markdown", odr::FileType::markdown)
|
|
51
|
+
.value("zip", odr::FileType::zip)
|
|
52
|
+
.value("compound_file_binary_format",
|
|
53
|
+
odr::FileType::compound_file_binary_format)
|
|
54
|
+
.value("portable_network_graphics",
|
|
55
|
+
odr::FileType::portable_network_graphics)
|
|
56
|
+
.value("graphics_interchange_format",
|
|
57
|
+
odr::FileType::graphics_interchange_format)
|
|
58
|
+
.value("jpeg", odr::FileType::jpeg)
|
|
59
|
+
.value("bitmap_image_file", odr::FileType::bitmap_image_file)
|
|
60
|
+
.value("starview_metafile", odr::FileType::starview_metafile);
|
|
61
|
+
|
|
62
|
+
py::enum_<odr::FileCategory>(m, "FileCategory")
|
|
63
|
+
.value("unknown", odr::FileCategory::unknown)
|
|
64
|
+
.value("text", odr::FileCategory::text)
|
|
65
|
+
.value("image", odr::FileCategory::image)
|
|
66
|
+
.value("archive", odr::FileCategory::archive)
|
|
67
|
+
.value("document", odr::FileCategory::document);
|
|
68
|
+
|
|
69
|
+
py::enum_<odr::FileLocation>(m, "FileLocation")
|
|
70
|
+
.value("memory", odr::FileLocation::memory)
|
|
71
|
+
.value("disk", odr::FileLocation::disk);
|
|
72
|
+
|
|
73
|
+
py::enum_<odr::EncryptionState>(m, "EncryptionState")
|
|
74
|
+
.value("unknown", odr::EncryptionState::unknown)
|
|
75
|
+
.value("not_encrypted", odr::EncryptionState::not_encrypted)
|
|
76
|
+
.value("encrypted", odr::EncryptionState::encrypted)
|
|
77
|
+
.value("decrypted", odr::EncryptionState::decrypted);
|
|
78
|
+
|
|
79
|
+
py::class_<odr::FileMeta>(m, "FileMeta")
|
|
80
|
+
.def_readwrite("type", &odr::FileMeta::type)
|
|
81
|
+
.def_readwrite("password_encrypted", &odr::FileMeta::password_encrypted)
|
|
82
|
+
.def_readwrite("document_meta", &odr::FileMeta::document_meta);
|
|
83
|
+
|
|
84
|
+
py::class_<odr::DocumentMeta>(m, "DocumentMeta")
|
|
85
|
+
.def_readwrite("document_type", &odr::DocumentMeta::document_type)
|
|
86
|
+
.def_readwrite("entry_count", &odr::DocumentMeta::entry_count);
|
|
87
|
+
|
|
88
|
+
py::class_<odr::File>(m, "File")
|
|
89
|
+
.def(py::init<const std::string &>())
|
|
90
|
+
.def("is_valid", &odr::File::operator bool)
|
|
91
|
+
.def("location", &odr::File::location)
|
|
92
|
+
.def("size", &odr::File::size);
|
|
93
|
+
|
|
94
|
+
py::class_<odr::DecodedFile>(m, "DecodedFile")
|
|
95
|
+
.def(py::init<const odr::File &>())
|
|
96
|
+
.def(py::init<const std::string &>())
|
|
97
|
+
.def("is_valid", &odr::DecodedFile::operator bool)
|
|
98
|
+
.def("file_type", &odr::DecodedFile::file_type)
|
|
99
|
+
.def("file_category", &odr::DecodedFile::file_category)
|
|
100
|
+
.def("file_meta", &odr::DecodedFile::file_meta)
|
|
101
|
+
.def("file", &odr::DecodedFile::file)
|
|
102
|
+
.def("is_text_file", &odr::DecodedFile::is_text_file)
|
|
103
|
+
.def("is_image_file", &odr::DecodedFile::is_image_file)
|
|
104
|
+
.def("is_archive_file", &odr::DecodedFile::is_archive_file)
|
|
105
|
+
.def("is_document_file", &odr::DecodedFile::is_document_file)
|
|
106
|
+
.def("is_pdf_file", &odr::DecodedFile::is_pdf_file)
|
|
107
|
+
.def("text_file", &odr::DecodedFile::text_file)
|
|
108
|
+
.def("image_file", &odr::DecodedFile::image_file)
|
|
109
|
+
.def("archive_file", &odr::DecodedFile::archive_file)
|
|
110
|
+
.def("document_file", &odr::DecodedFile::document_file)
|
|
111
|
+
.def("pdf_file", &odr::DecodedFile::pdf_file);
|
|
112
|
+
|
|
113
|
+
py::class_<odr::TextFile>(m, "TextFile")
|
|
114
|
+
.def("is_valid", &odr::TextFile::operator bool)
|
|
115
|
+
.def("charset", &odr::TextFile::charset)
|
|
116
|
+
.def("text", &odr::TextFile::text);
|
|
117
|
+
|
|
118
|
+
py::class_<odr::ImageFile>(m, "ImageFile")
|
|
119
|
+
.def("is_valid", &odr::ImageFile::operator bool);
|
|
120
|
+
|
|
121
|
+
py::class_<odr::ArchiveFile>(m, "ArchiveFile")
|
|
122
|
+
.def("is_valid", &odr::ArchiveFile::operator bool);
|
|
123
|
+
|
|
124
|
+
py::class_<odr::DocumentFile>(m, "DocumentFile")
|
|
125
|
+
.def("is_valid", &odr::DocumentFile::operator bool)
|
|
126
|
+
.def("password_encrypted", &odr::DocumentFile::password_encrypted)
|
|
127
|
+
.def("encryption_state", &odr::DocumentFile::encryption_state)
|
|
128
|
+
.def("decrypt", &odr::DocumentFile::decrypt)
|
|
129
|
+
.def("document_type", &odr::DocumentFile::document_type)
|
|
130
|
+
.def("document_meta", &odr::DocumentFile::document_meta)
|
|
131
|
+
.def("document", &odr::DocumentFile::document);
|
|
132
|
+
|
|
133
|
+
py::class_<odr::PdfFile>(m, "PdfFile")
|
|
134
|
+
.def("is_valid", &odr::PdfFile::operator bool);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
{
|
|
138
|
+
py::class_<odr::Filesystem>(m, "Filesystem")
|
|
139
|
+
.def("is_valid", &odr::Filesystem::operator bool)
|
|
140
|
+
.def("exists", &odr::Filesystem::exists)
|
|
141
|
+
.def("is_file", &odr::Filesystem::is_file)
|
|
142
|
+
.def("is_directory", &odr::Filesystem::is_directory)
|
|
143
|
+
.def("file_walker", &odr::Filesystem::file_walker)
|
|
144
|
+
.def("open", &odr::Filesystem::open);
|
|
145
|
+
|
|
146
|
+
py::class_<odr::FileWalker>(m, "FileWalker")
|
|
147
|
+
.def("is_valid", &odr::FileWalker::operator bool)
|
|
148
|
+
.def("next", &odr::FileWalker::next);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
{
|
|
152
|
+
py::enum_<odr::DocumentType>(m, "DocumentType")
|
|
153
|
+
.value("unknown", odr::DocumentType::unknown)
|
|
154
|
+
.value("text", odr::DocumentType::text)
|
|
155
|
+
.value("presentation", odr::DocumentType::presentation)
|
|
156
|
+
.value("spreadsheet", odr::DocumentType::spreadsheet)
|
|
157
|
+
.value("drawing", odr::DocumentType::drawing);
|
|
158
|
+
|
|
159
|
+
py::class_<odr::Document>(m, "Document")
|
|
160
|
+
.def("editable", &odr::Document::editable)
|
|
161
|
+
.def("savable", &odr::Document::savable, py::arg("encrypted") = false)
|
|
162
|
+
.def("save", py::overload_cast<const std::string &>(
|
|
163
|
+
&odr::Document::save, py::const_))
|
|
164
|
+
.def("file_type", &odr::Document::file_type)
|
|
165
|
+
.def("document_type", &odr::Document::document_type)
|
|
166
|
+
.def("root_element", &odr::Document::root_element)
|
|
167
|
+
.def("files", &odr::Document::files);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
{
|
|
171
|
+
py::enum_<odr::ElementType>(m, "ElementType")
|
|
172
|
+
.value("none", odr::ElementType::none)
|
|
173
|
+
.value("root", odr::ElementType::root)
|
|
174
|
+
.value("slide", odr::ElementType::slide)
|
|
175
|
+
.value("sheet", odr::ElementType::sheet)
|
|
176
|
+
.value("page", odr::ElementType::page)
|
|
177
|
+
.value("master_page", odr::ElementType::master_page)
|
|
178
|
+
.value("text", odr::ElementType::text)
|
|
179
|
+
.value("line_break", odr::ElementType::line_break)
|
|
180
|
+
.value("page_break", odr::ElementType::page_break)
|
|
181
|
+
.value("paragraph", odr::ElementType::paragraph)
|
|
182
|
+
.value("span", odr::ElementType::span)
|
|
183
|
+
.value("link", odr::ElementType::link)
|
|
184
|
+
.value("bookmark", odr::ElementType::bookmark)
|
|
185
|
+
.value("list", odr::ElementType::list)
|
|
186
|
+
.value("list_item", odr::ElementType::list_item)
|
|
187
|
+
.value("table", odr::ElementType::table)
|
|
188
|
+
.value("table_column", odr::ElementType::table_column)
|
|
189
|
+
.value("table_row", odr::ElementType::table_row)
|
|
190
|
+
.value("table_cell", odr::ElementType::table_cell)
|
|
191
|
+
.value("frame", odr::ElementType::frame)
|
|
192
|
+
.value("image", odr::ElementType::image)
|
|
193
|
+
.value("rect", odr::ElementType::rect)
|
|
194
|
+
.value("line", odr::ElementType::line)
|
|
195
|
+
.value("circle", odr::ElementType::circle)
|
|
196
|
+
.value("custom_shape", odr::ElementType::custom_shape)
|
|
197
|
+
.value("group", odr::ElementType::group);
|
|
198
|
+
|
|
199
|
+
py::enum_<odr::AnchorType>(m, "AnchorType")
|
|
200
|
+
.value("as_char", odr::AnchorType::as_char)
|
|
201
|
+
.value("at_char", odr::AnchorType::at_char)
|
|
202
|
+
.value("at_frame", odr::AnchorType::at_frame)
|
|
203
|
+
.value("at_page", odr::AnchorType::at_page)
|
|
204
|
+
.value("at_paragraph", odr::AnchorType::at_paragraph);
|
|
205
|
+
|
|
206
|
+
py::enum_<odr::ValueType>(m, "ValueType")
|
|
207
|
+
.value("unknown", odr::ValueType::unknown)
|
|
208
|
+
.value("string", odr::ValueType::string)
|
|
209
|
+
.value("float_number", odr::ValueType::float_number);
|
|
210
|
+
|
|
211
|
+
py::class_<odr::Element>(m, "Element")
|
|
212
|
+
.def("is_valid", &odr::Element::operator bool)
|
|
213
|
+
.def("type", &odr::Element::type)
|
|
214
|
+
.def("parent", &odr::Element::parent)
|
|
215
|
+
.def("first_child", &odr::Element::first_child)
|
|
216
|
+
.def("previous_sibling", &odr::Element::previous_sibling)
|
|
217
|
+
.def("next_sibling", &odr::Element::next_sibling)
|
|
218
|
+
.def("is_editable", &odr::Element::is_editable);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
{
|
|
222
|
+
py::enum_<odr::HtmlTableGridlines>(m, "HtmlTableGridlines")
|
|
223
|
+
.value("none", odr::HtmlTableGridlines::none)
|
|
224
|
+
.value("soft", odr::HtmlTableGridlines::soft)
|
|
225
|
+
.value("hard", odr::HtmlTableGridlines::hard);
|
|
226
|
+
|
|
227
|
+
py::class_<odr::HtmlConfig>(m, "HtmlConfig")
|
|
228
|
+
.def(py::init<>())
|
|
229
|
+
.def_readwrite("compact_presentation",
|
|
230
|
+
&odr::HtmlConfig::compact_presentation)
|
|
231
|
+
.def_readwrite("compact_spreadsheet",
|
|
232
|
+
&odr::HtmlConfig::compact_spreadsheet)
|
|
233
|
+
.def_readwrite("compact_drawing", &odr::HtmlConfig::compact_drawing)
|
|
234
|
+
.def_readwrite("text_document_output_file_name",
|
|
235
|
+
&odr::HtmlConfig::text_document_output_file_name)
|
|
236
|
+
.def_readwrite("presentation_output_file_name",
|
|
237
|
+
&odr::HtmlConfig::presentation_output_file_name)
|
|
238
|
+
.def_readwrite("spreadsheet_output_file_name",
|
|
239
|
+
&odr::HtmlConfig::spreadsheet_output_file_name)
|
|
240
|
+
.def_readwrite("drawing_output_file_name",
|
|
241
|
+
&odr::HtmlConfig::drawing_output_file_name)
|
|
242
|
+
.def_readwrite("slide_output_file_name",
|
|
243
|
+
&odr::HtmlConfig::slide_output_file_name)
|
|
244
|
+
.def_readwrite("sheet_output_file_name",
|
|
245
|
+
&odr::HtmlConfig::sheet_output_file_name)
|
|
246
|
+
.def_readwrite("page_output_file_name",
|
|
247
|
+
&odr::HtmlConfig::page_output_file_name)
|
|
248
|
+
.def_readwrite("embed_resources", &odr::HtmlConfig::embed_resources)
|
|
249
|
+
.def_readwrite("external_resource_path",
|
|
250
|
+
&odr::HtmlConfig::external_resource_path)
|
|
251
|
+
.def_readwrite("relative_resource_paths",
|
|
252
|
+
&odr::HtmlConfig::relative_resource_paths)
|
|
253
|
+
.def_readwrite("editable", &odr::HtmlConfig::editable)
|
|
254
|
+
.def_readwrite("text_document_margin",
|
|
255
|
+
&odr::HtmlConfig::text_document_margin)
|
|
256
|
+
.def_readwrite("spreadsheet_limit", &odr::HtmlConfig::spreadsheet_limit)
|
|
257
|
+
.def_readwrite("spreadsheet_limit_by_content",
|
|
258
|
+
&odr::HtmlConfig::spreadsheet_limit_by_content)
|
|
259
|
+
.def_readwrite("spreadsheet_gridlines",
|
|
260
|
+
&odr::HtmlConfig::spreadsheet_gridlines)
|
|
261
|
+
.def_readwrite("format_html", &odr::HtmlConfig::format_html)
|
|
262
|
+
.def_readwrite("html_indent", &odr::HtmlConfig::html_indent);
|
|
263
|
+
|
|
264
|
+
py::class_<odr::Html>(m, "Html")
|
|
265
|
+
.def("file_type", &odr::Html::file_type)
|
|
266
|
+
.def("pages", &odr::Html::pages)
|
|
267
|
+
.def("edit", &odr::Html::edit)
|
|
268
|
+
.def("save", &odr::Html::save);
|
|
269
|
+
|
|
270
|
+
py::class_<odr::HtmlPage>(m, "HtmlPage")
|
|
271
|
+
.def_readwrite("name", &odr::HtmlPage::name)
|
|
272
|
+
.def_readwrite("path", &odr::HtmlPage::path);
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
{
|
|
276
|
+
m.def("open", &odr::OpenDocumentReader::open);
|
|
277
|
+
|
|
278
|
+
m.def("copy_resources", &odr::OpenDocumentReader::copy_resources);
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
{
|
|
282
|
+
auto m_html = m.def_submodule("html");
|
|
283
|
+
|
|
284
|
+
m_html.def(
|
|
285
|
+
"translate",
|
|
286
|
+
py::overload_cast<const odr::DecodedFile &, const std::string &,
|
|
287
|
+
const odr::HtmlConfig &>(&odr::html::translate));
|
|
288
|
+
}
|
|
289
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: pyodr
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: It's Android's first OpenOffice Document Reader for Python!
|
|
5
|
+
Author: Andreas Stefl
|
|
6
|
+
Author-email: stefl.andreas@gmail.com
|
|
7
|
+
Requires-Python: >=3.7
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
Provides-Extra: dev
|
|
10
|
+
Requires-Dist: black; extra == "dev"
|
|
11
|
+
Provides-Extra: test
|
|
12
|
+
Requires-Dist: pytest>=6.0; extra == "test"
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
.gitignore
|
|
2
|
+
CMakeLists.txt
|
|
3
|
+
README.md
|
|
4
|
+
conanfile.txt
|
|
5
|
+
pyproject.toml
|
|
6
|
+
setup.py
|
|
7
|
+
.github/config/macos-13/conan/profiles/default
|
|
8
|
+
.github/config/ubuntu-22.04/conan/profiles/default
|
|
9
|
+
.github/config/windows-2022/conan/profiles/default
|
|
10
|
+
.github/workflows/format.yaml
|
|
11
|
+
.github/workflows/pip.yaml
|
|
12
|
+
.github/workflows/wheels.yaml
|
|
13
|
+
src/pyodr/CMakeLists.txt
|
|
14
|
+
src/pyodr/__init__.py
|
|
15
|
+
src/pyodr/cli.py
|
|
16
|
+
src/pyodr/core.cpp
|
|
17
|
+
src/pyodr.egg-info/PKG-INFO
|
|
18
|
+
src/pyodr.egg-info/SOURCES.txt
|
|
19
|
+
src/pyodr.egg-info/dependency_links.txt
|
|
20
|
+
src/pyodr.egg-info/entry_points.txt
|
|
21
|
+
src/pyodr.egg-info/requires.txt
|
|
22
|
+
src/pyodr.egg-info/top_level.txt
|
|
23
|
+
tests/test_foobar.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
pyodr
|