Skip to content

Commit 9ab57ab

Browse files
committed
cli and skip
1 parent 33818ee commit 9ab57ab

File tree

4 files changed

+45
-1
lines changed

4 files changed

+45
-1
lines changed

.github/workflows/wheels.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737
env:
3838
MACOSX_DEPLOYMENT_TARGET: 10.15
3939
CIBW_ARCHS_MACOS: auto universal2
40-
CIBW_SKIP: "*-win32 *-manylinux_i686"
40+
CIBW_SKIP: "*-win32 *-manylinux_i686 cp312-win_amd64 cp37-musllinux_x86_64"
4141
CIBW_BUILD_VERBOSITY: 1
4242
- name: Verify clean directory
4343
run: git diff --exit-code

setup.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,7 @@
3636
"test": ["pytest>=6.0"],
3737
},
3838
conan_profile_settings={"compiler.cppstd": "20"},
39+
entry_points = {
40+
"console_scripts": ["pyodr=pyodr.cli:main"],
41+
},
3942
)

src/pyodr/cli.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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)

src/pyodr/core.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include <pybind11/pybind11.h>
2+
#include <pybind11/stl.h>
23

34
#include <odr/document.hpp>
45
#include <odr/document_element.hpp>

0 commit comments

Comments
 (0)