gotenberg-client 0.7.0__tar.gz → 0.8.2__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.
- {gotenberg_client-0.7.0 → gotenberg_client-0.8.2}/.pre-commit-config.yaml +3 -3
- {gotenberg_client-0.7.0 → gotenberg_client-0.8.2}/CHANGELOG.md +35 -0
- {gotenberg_client-0.7.0 → gotenberg_client-0.8.2}/PKG-INFO +34 -6
- {gotenberg_client-0.7.0 → gotenberg_client-0.8.2}/README.md +29 -0
- gotenberg_client-0.8.2/docs/roadmap.md +3 -0
- {gotenberg_client-0.7.0 → gotenberg_client-0.8.2}/docs/routes.md +36 -2
- {gotenberg_client-0.7.0 → gotenberg_client-0.8.2}/pyproject.toml +15 -13
- {gotenberg_client-0.7.0 → gotenberg_client-0.8.2}/src/gotenberg_client/__about__.py +1 -1
- {gotenberg_client-0.7.0 → gotenberg_client-0.8.2}/src/gotenberg_client/__init__.py +7 -3
- {gotenberg_client-0.7.0 → gotenberg_client-0.8.2}/src/gotenberg_client/_base.py +6 -8
- {gotenberg_client-0.7.0 → gotenberg_client-0.8.2}/src/gotenberg_client/_client.py +3 -5
- {gotenberg_client-0.7.0 → gotenberg_client-0.8.2}/src/gotenberg_client/_convert/chromium.py +7 -6
- {gotenberg_client-0.7.0 → gotenberg_client-0.8.2}/src/gotenberg_client/_convert/common.py +149 -3
- {gotenberg_client-0.7.0 → gotenberg_client-0.8.2}/src/gotenberg_client/_convert/libre_office.py +3 -3
- {gotenberg_client-0.7.0 → gotenberg_client-0.8.2}/src/gotenberg_client/_convert/pdfa.py +3 -3
- {gotenberg_client-0.7.0 → gotenberg_client-0.8.2}/src/gotenberg_client/_errors.py +8 -0
- {gotenberg_client-0.7.0 → gotenberg_client-0.8.2}/src/gotenberg_client/_merge.py +1 -2
- {gotenberg_client-0.7.0 → gotenberg_client-0.8.2}/src/gotenberg_client/_utils.py +2 -3
- {gotenberg_client-0.7.0 → gotenberg_client-0.8.2}/src/gotenberg_client/options.py +17 -9
- {gotenberg_client-0.7.0 → gotenberg_client-0.8.2}/tests/conftest.py +64 -5
- gotenberg_client-0.8.2/tests/docker/content/favicon.ico +0 -0
- gotenberg_client-0.8.2/tests/docker/content/index.html +9 -0
- gotenberg_client-0.8.2/tests/docker/docker-compose.ci-test-edge.yml +24 -0
- gotenberg_client-0.8.2/tests/docker/docker-compose.ci-test.yml +24 -0
- {gotenberg_client-0.7.0 → gotenberg_client-0.8.2}/tests/test_convert_chromium_html.py +8 -10
- {gotenberg_client-0.7.0 → gotenberg_client-0.8.2}/tests/test_convert_chromium_screenshots.py +23 -22
- {gotenberg_client-0.7.0 → gotenberg_client-0.8.2}/tests/test_convert_chromium_url.py +37 -47
- gotenberg_client-0.8.2/tests/test_metadata.py +183 -0
- {gotenberg_client-0.7.0 → gotenberg_client-0.8.2}/tests/utils.py +9 -16
- gotenberg_client-0.7.0/docs/roadmap.md +0 -12
- {gotenberg_client-0.7.0 → gotenberg_client-0.8.2}/.codecov.yml +0 -0
- {gotenberg_client-0.7.0 → gotenberg_client-0.8.2}/.editorconfig +0 -0
- {gotenberg_client-0.7.0 → gotenberg_client-0.8.2}/.gitignore +0 -0
- {gotenberg_client-0.7.0 → gotenberg_client-0.8.2}/.vscode/settings.json +0 -0
- {gotenberg_client-0.7.0 → gotenberg_client-0.8.2}/LICENSE +0 -0
- {gotenberg_client-0.7.0 → gotenberg_client-0.8.2}/docs/.override/main.html +0 -0
- {gotenberg_client-0.7.0 → gotenberg_client-0.8.2}/docs/changelog.md +0 -0
- {gotenberg_client-0.7.0 → gotenberg_client-0.8.2}/docs/index.md +0 -0
- {gotenberg_client-0.7.0 → gotenberg_client-0.8.2}/docs/maybe-logo.webp +0 -0
- {gotenberg_client-0.7.0 → gotenberg_client-0.8.2}/docs/usage.md +0 -0
- {gotenberg_client-0.7.0 → gotenberg_client-0.8.2}/mkdocs.yml +0 -0
- {gotenberg_client-0.7.0 → gotenberg_client-0.8.2}/src/gotenberg_client/_convert/__init__.py +0 -0
- {gotenberg_client-0.7.0 → gotenberg_client-0.8.2}/src/gotenberg_client/_health.py +0 -0
- {gotenberg_client-0.7.0 → gotenberg_client-0.8.2}/src/gotenberg_client/_metrics.py +0 -0
- {gotenberg_client-0.7.0 → gotenberg_client-0.8.2}/src/gotenberg_client/_types.py +0 -0
- {gotenberg_client-0.7.0 → gotenberg_client-0.8.2}/src/gotenberg_client/py.typed +0 -0
- {gotenberg_client-0.7.0 → gotenberg_client-0.8.2}/src/gotenberg_client/responses.py +0 -0
- {gotenberg_client-0.7.0 → gotenberg_client-0.8.2}/tests/__init__.py +0 -0
- {gotenberg_client-0.7.0 → gotenberg_client-0.8.2}/tests/samples/a_merge_second.pdf +0 -0
- {gotenberg_client-0.7.0 → gotenberg_client-0.8.2}/tests/samples/basic.html +0 -0
- {gotenberg_client-0.7.0 → gotenberg_client-0.8.2}/tests/samples/complex.html +0 -0
- {gotenberg_client-0.7.0 → gotenberg_client-0.8.2}/tests/samples/font.woff +0 -0
- {gotenberg_client-0.7.0 → gotenberg_client-0.8.2}/tests/samples/footer.html +0 -0
- {gotenberg_client-0.7.0 → gotenberg_client-0.8.2}/tests/samples/header.html +0 -0
- {gotenberg_client-0.7.0 → gotenberg_client-0.8.2}/tests/samples/img.gif +0 -0
- {gotenberg_client-0.7.0 → gotenberg_client-0.8.2}/tests/samples/markdown1.md +0 -0
- {gotenberg_client-0.7.0 → gotenberg_client-0.8.2}/tests/samples/markdown2.md +0 -0
- {gotenberg_client-0.7.0 → gotenberg_client-0.8.2}/tests/samples/markdown_index.html +0 -0
- {gotenberg_client-0.7.0 → gotenberg_client-0.8.2}/tests/samples/sample.docx +0 -0
- {gotenberg_client-0.7.0 → gotenberg_client-0.8.2}/tests/samples/sample.ods +0 -0
- {gotenberg_client-0.7.0 → gotenberg_client-0.8.2}/tests/samples/sample.odt +0 -0
- {gotenberg_client-0.7.0 → gotenberg_client-0.8.2}/tests/samples/sample.xlsx +0 -0
- {gotenberg_client-0.7.0 → gotenberg_client-0.8.2}/tests/samples/sample1.pdf +0 -0
- {gotenberg_client-0.7.0 → gotenberg_client-0.8.2}/tests/samples/style.css +0 -0
- {gotenberg_client-0.7.0 → gotenberg_client-0.8.2}/tests/samples/z_first_merge.pdf +0 -0
- {gotenberg_client-0.7.0 → gotenberg_client-0.8.2}/tests/test_convert_chromium_markdown.py +0 -0
- {gotenberg_client-0.7.0 → gotenberg_client-0.8.2}/tests/test_convert_libre_office.py +0 -0
- {gotenberg_client-0.7.0 → gotenberg_client-0.8.2}/tests/test_convert_pdf_a.py +0 -0
- {gotenberg_client-0.7.0 → gotenberg_client-0.8.2}/tests/test_health.py +0 -0
- {gotenberg_client-0.7.0 → gotenberg_client-0.8.2}/tests/test_merge.py +0 -0
- {gotenberg_client-0.7.0 → gotenberg_client-0.8.2}/tests/test_misc_stuff.py +0 -0
|
@@ -30,7 +30,7 @@ repos:
|
|
|
30
30
|
- id: detect-private-key
|
|
31
31
|
# See https://github.com/prettier/prettier/issues/15742 for the fork reason
|
|
32
32
|
- repo: https://github.com/rbubley/mirrors-prettier
|
|
33
|
-
rev: "v3.
|
|
33
|
+
rev: "v3.4.2"
|
|
34
34
|
hooks:
|
|
35
35
|
- id: prettier
|
|
36
36
|
types_or:
|
|
@@ -45,13 +45,13 @@ repos:
|
|
|
45
45
|
- id: codespell
|
|
46
46
|
# Python hooks
|
|
47
47
|
- repo: https://github.com/astral-sh/ruff-pre-commit
|
|
48
|
-
rev: 'v0.
|
|
48
|
+
rev: 'v0.8.2'
|
|
49
49
|
hooks:
|
|
50
50
|
# Run the linter.
|
|
51
51
|
- id: ruff
|
|
52
52
|
# Run the formatter.
|
|
53
53
|
- id: ruff-format
|
|
54
54
|
- repo: https://github.com/tox-dev/pyproject-fmt
|
|
55
|
-
rev: "
|
|
55
|
+
rev: "v2.5.0"
|
|
56
56
|
hooks:
|
|
57
57
|
- id: pyproject-fmt
|
|
@@ -5,6 +5,41 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [0.8.2] - 2024-12-17
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
|
|
12
|
+
- Bump pypa/gh-action-pypi-publish from 1.12.2 to 1.12.3, fixing core metadata publishing issue
|
|
13
|
+
|
|
14
|
+
## [0.8.1] - 2024-12-17
|
|
15
|
+
|
|
16
|
+
### Fixed
|
|
17
|
+
|
|
18
|
+
- Relaxed version restriction on `httpx`
|
|
19
|
+
|
|
20
|
+
### Changed
|
|
21
|
+
|
|
22
|
+
- Test in CI using Gotenberg 8.14.1
|
|
23
|
+
|
|
24
|
+
## [0.8.0] - 2024-12-11
|
|
25
|
+
|
|
26
|
+
### Breaking Change
|
|
27
|
+
|
|
28
|
+
- Dropped support for Python 3.8 ([#43](https://github.com/stumpylog/gotenberg-client/pull/43))
|
|
29
|
+
|
|
30
|
+
### Added
|
|
31
|
+
|
|
32
|
+
- Official support and testing for Python 3.13 ([#25](https://github.com/stumpylog/gotenberg-client/pull/25))
|
|
33
|
+
- Support for setting PDF metadata ([#42](https://github.com/stumpylog/gotenberg-client/pull/42))
|
|
34
|
+
- Initial work by @spechtx in ([#40](https://github.com/stumpylog/gotenberg-client/pull/40))
|
|
35
|
+
- Integrated Codecov test analytics ([#44](https://github.com/stumpylog/gotenberg-client/pull/44))
|
|
36
|
+
|
|
37
|
+
### Changed
|
|
38
|
+
|
|
39
|
+
- Use `pytest-docker` to manage Docker image services ([#36](https://github.com/stumpylog/gotenberg-client/pull/36))
|
|
40
|
+
- Bump Bump pypa/gh-action-pypi-publish from 1.10.2 to 1.12.2 by @dependabot ([#41](https://github.com/stumpylog/gotenberg-client/pull/41))
|
|
41
|
+
- Bump codecov/codecov-action from 4 to 5 by @dependabot ([#41](https://github.com/stumpylog/gotenberg-client/pull/41))
|
|
42
|
+
|
|
8
43
|
## [0.7.0] - 2024-10-08
|
|
9
44
|
|
|
10
45
|
### Fixed
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: gotenberg-client
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.8.2
|
|
4
4
|
Summary: A Python client for interfacing with the Gotenberg API
|
|
5
5
|
Project-URL: Changelog, https://github.com/stumpylog/gotenberg-client/blob/main/CHANGELOG.md
|
|
6
6
|
Project-URL: Documentation, https://stumpylog.github.io/gotenberg-client/
|
|
@@ -17,16 +17,15 @@ Classifier: License :: OSI Approved :: Mozilla Public License 2.0 (MPL 2.0)
|
|
|
17
17
|
Classifier: Operating System :: OS Independent
|
|
18
18
|
Classifier: Programming Language :: Python
|
|
19
19
|
Classifier: Programming Language :: Python :: 3 :: Only
|
|
20
|
-
Classifier: Programming Language :: Python :: 3.8
|
|
21
20
|
Classifier: Programming Language :: Python :: 3.9
|
|
22
21
|
Classifier: Programming Language :: Python :: 3.10
|
|
23
22
|
Classifier: Programming Language :: Python :: 3.11
|
|
24
23
|
Classifier: Programming Language :: Python :: 3.12
|
|
24
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
25
25
|
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
26
26
|
Classifier: Programming Language :: Python :: Implementation :: PyPy
|
|
27
|
-
Requires-Python: >=3.
|
|
28
|
-
Requires-Dist: httpx[http2]
|
|
29
|
-
Requires-Dist: httpx[http2]~=0.27; python_version >= '3.9'
|
|
27
|
+
Requires-Python: >=3.9
|
|
28
|
+
Requires-Dist: httpx[http2]>=0.27
|
|
30
29
|
Requires-Dist: typing-extensions; python_version < '3.11'
|
|
31
30
|
Provides-Extra: magic
|
|
32
31
|
Requires-Dist: python-magic; extra == 'magic'
|
|
@@ -136,6 +135,35 @@ with GotenbergClient("http://localhost:3000") as client:
|
|
|
136
135
|
response.to_file(Path("my-world.pdf"))
|
|
137
136
|
```
|
|
138
137
|
|
|
138
|
+
Adding metadata to a PDF:
|
|
139
|
+
|
|
140
|
+
This example shows how to add metadata to your generated PDF. All metadata fields are optional and include:
|
|
141
|
+
|
|
142
|
+
- Document info (title, author, subject, keywords)
|
|
143
|
+
- Dates (creation, modification)
|
|
144
|
+
- Technical details (pdf version, creator, producer)
|
|
145
|
+
- PDF standards (trapped status, marked status)
|
|
146
|
+
|
|
147
|
+
```python
|
|
148
|
+
from gotenberg_client import GotenbergClient
|
|
149
|
+
from datetime import datetime
|
|
150
|
+
|
|
151
|
+
with GotenbergClient("http://localhost:3000") as client:
|
|
152
|
+
with client.chromium.html_to_pdf() as route:
|
|
153
|
+
response = (route
|
|
154
|
+
.index("my-index.html")
|
|
155
|
+
.metadata(
|
|
156
|
+
title="My Document",
|
|
157
|
+
author="John Doe",
|
|
158
|
+
subject="Example PDF",
|
|
159
|
+
keywords=["sample", "document", "test"],
|
|
160
|
+
creation_date=datetime.now(),
|
|
161
|
+
trapped="Unknown"
|
|
162
|
+
)
|
|
163
|
+
.run())
|
|
164
|
+
response.to_file(Path("my-index.pdf"))
|
|
165
|
+
```
|
|
166
|
+
|
|
139
167
|
To ensure the proper clean up of all used resources, both the client and the route(s) should be
|
|
140
168
|
used as context manager. If for some reason you cannot, you should `.close` the client and any
|
|
141
169
|
routes:
|
|
@@ -102,6 +102,35 @@ with GotenbergClient("http://localhost:3000") as client:
|
|
|
102
102
|
response.to_file(Path("my-world.pdf"))
|
|
103
103
|
```
|
|
104
104
|
|
|
105
|
+
Adding metadata to a PDF:
|
|
106
|
+
|
|
107
|
+
This example shows how to add metadata to your generated PDF. All metadata fields are optional and include:
|
|
108
|
+
|
|
109
|
+
- Document info (title, author, subject, keywords)
|
|
110
|
+
- Dates (creation, modification)
|
|
111
|
+
- Technical details (pdf version, creator, producer)
|
|
112
|
+
- PDF standards (trapped status, marked status)
|
|
113
|
+
|
|
114
|
+
```python
|
|
115
|
+
from gotenberg_client import GotenbergClient
|
|
116
|
+
from datetime import datetime
|
|
117
|
+
|
|
118
|
+
with GotenbergClient("http://localhost:3000") as client:
|
|
119
|
+
with client.chromium.html_to_pdf() as route:
|
|
120
|
+
response = (route
|
|
121
|
+
.index("my-index.html")
|
|
122
|
+
.metadata(
|
|
123
|
+
title="My Document",
|
|
124
|
+
author="John Doe",
|
|
125
|
+
subject="Example PDF",
|
|
126
|
+
keywords=["sample", "document", "test"],
|
|
127
|
+
creation_date=datetime.now(),
|
|
128
|
+
trapped="Unknown"
|
|
129
|
+
)
|
|
130
|
+
.run())
|
|
131
|
+
response.to_file(Path("my-index.pdf"))
|
|
132
|
+
```
|
|
133
|
+
|
|
105
134
|
To ensure the proper clean up of all used resources, both the client and the route(s) should be
|
|
106
135
|
used as context manager. If for some reason you cannot, you should `.close` the client and any
|
|
107
136
|
routes:
|
|
@@ -95,11 +95,45 @@ These options are not yet implemented
|
|
|
95
95
|
| `pdfa` | `.pdf_format()` | `PdfAFormat` | |
|
|
96
96
|
| `pdfua` | <ul><li>`enable_universal_access()`<li>`disable_universal_access()`</li></ul> | N/A | |
|
|
97
97
|
|
|
98
|
-
#### Metadata
|
|
98
|
+
#### PDF Metadata Support
|
|
99
99
|
|
|
100
100
|
[Gotenberg Documentation](https://gotenberg.dev/docs/routes#metadata-chromium)
|
|
101
101
|
|
|
102
|
-
|
|
102
|
+
Add metadata to your PDFs:
|
|
103
|
+
|
|
104
|
+
```python
|
|
105
|
+
from gotenberg_client import GotenbergClient
|
|
106
|
+
from datetime import datetime
|
|
107
|
+
|
|
108
|
+
with GotenbergClient("http://localhost:3000") as client:
|
|
109
|
+
with client.chromium.html_to_pdf() as route:
|
|
110
|
+
response = (route
|
|
111
|
+
.index("my-index.html")
|
|
112
|
+
.metadata(
|
|
113
|
+
title="My Document",
|
|
114
|
+
author="John Doe",
|
|
115
|
+
creation_date=datetime.now(),
|
|
116
|
+
keywords=["sample", "document"],
|
|
117
|
+
subject="Sample PDF Generation",
|
|
118
|
+
trapped="Unknown"
|
|
119
|
+
)
|
|
120
|
+
.run())
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
Supported metadata fields:
|
|
124
|
+
|
|
125
|
+
- `title`: Document title
|
|
126
|
+
- `author`: Document author
|
|
127
|
+
- `subject`: Document subject
|
|
128
|
+
- `keywords`: List of keywords
|
|
129
|
+
- `creator`: Creating application
|
|
130
|
+
- `creation_date`: Creation datetime
|
|
131
|
+
- `modification_date`: Last modification datetime
|
|
132
|
+
- `producer`: PDF producer
|
|
133
|
+
- `trapped`: Trapping status ('True', 'False', 'Unknown')
|
|
134
|
+
- `copyright`: Copyright information
|
|
135
|
+
- `marked`: PDF marked status
|
|
136
|
+
- `pdf_version`: PDF version number
|
|
103
137
|
|
|
104
138
|
## LibreOffice
|
|
105
139
|
|
|
@@ -16,7 +16,7 @@ license = "MPL-2.0"
|
|
|
16
16
|
authors = [
|
|
17
17
|
{ name = "Trenton H", email = "rda0128ou@mozmail.com" },
|
|
18
18
|
]
|
|
19
|
-
requires-python = ">=3.
|
|
19
|
+
requires-python = ">=3.9"
|
|
20
20
|
classifiers = [
|
|
21
21
|
"Development Status :: 4 - Beta",
|
|
22
22
|
"Environment :: Web Environment",
|
|
@@ -25,18 +25,17 @@ classifiers = [
|
|
|
25
25
|
"Operating System :: OS Independent",
|
|
26
26
|
"Programming Language :: Python",
|
|
27
27
|
"Programming Language :: Python :: 3 :: Only",
|
|
28
|
-
"Programming Language :: Python :: 3.8",
|
|
29
28
|
"Programming Language :: Python :: 3.9",
|
|
30
29
|
"Programming Language :: Python :: 3.10",
|
|
31
30
|
"Programming Language :: Python :: 3.11",
|
|
32
31
|
"Programming Language :: Python :: 3.12",
|
|
32
|
+
"Programming Language :: Python :: 3.13",
|
|
33
33
|
"Programming Language :: Python :: Implementation :: CPython",
|
|
34
34
|
"Programming Language :: Python :: Implementation :: PyPy",
|
|
35
35
|
]
|
|
36
36
|
dynamic = [ "version" ]
|
|
37
37
|
dependencies = [
|
|
38
|
-
"httpx[http2]
|
|
39
|
-
"httpx[http2]~=0.27; python_version>='3.9'",
|
|
38
|
+
"httpx[http2]>=0.27",
|
|
40
39
|
"typing-extensions; python_version<'3.11'",
|
|
41
40
|
]
|
|
42
41
|
|
|
@@ -64,7 +63,7 @@ installer = "uv"
|
|
|
64
63
|
|
|
65
64
|
[tool.hatch.envs.hatch-static-analysis]
|
|
66
65
|
# https://hatch.pypa.io/latest/config/internal/static-analysis/
|
|
67
|
-
dependencies = [ "ruff ~= 0.
|
|
66
|
+
dependencies = [ "ruff ~= 0.8" ]
|
|
68
67
|
config-path = "none"
|
|
69
68
|
|
|
70
69
|
[tool.hatch.envs.hatch-test]
|
|
@@ -74,19 +73,18 @@ randomize = true
|
|
|
74
73
|
dependencies = [
|
|
75
74
|
"coverage-enable-subprocess == 1.0",
|
|
76
75
|
"coverage[toml] ~= 7.6",
|
|
77
|
-
"pytest < 8.0; python_version < '3.9'",
|
|
78
76
|
"pytest ~= 8.3; python_version >= '3.9'",
|
|
79
77
|
"pytest-mock ~= 3.14",
|
|
80
78
|
"pytest-randomly ~= 3.15",
|
|
81
|
-
"pytest-rerunfailures ~=
|
|
79
|
+
"pytest-rerunfailures ~= 15.0",
|
|
82
80
|
"pytest-xdist[psutil] ~= 3.6",
|
|
83
81
|
]
|
|
84
82
|
extra-dependencies = [
|
|
85
83
|
"pytest-sugar",
|
|
86
|
-
"pytest-httpx
|
|
87
|
-
"pytest-httpx ~= 0.22; python_version < '3.9'",
|
|
84
|
+
"pytest-httpx ~= 0.35",
|
|
88
85
|
"pikepdf",
|
|
89
86
|
"python-magic",
|
|
87
|
+
"pytest-docker ~= 3.1",
|
|
90
88
|
]
|
|
91
89
|
extra-args = [ "--maxprocesses=8", "--pythonwarnings=all" ]
|
|
92
90
|
|
|
@@ -109,7 +107,7 @@ cov-report = [
|
|
|
109
107
|
]
|
|
110
108
|
|
|
111
109
|
[[tool.hatch.envs.hatch-test.matrix]]
|
|
112
|
-
python = [ "3.
|
|
110
|
+
python = [ "3.9", "3.10", "3.11", "3.12", "3.13", "pypy3.9", "pypy3.10" ]
|
|
113
111
|
|
|
114
112
|
#
|
|
115
113
|
# Custom Environments
|
|
@@ -117,11 +115,11 @@ python = [ "3.8", "3.9", "3.10", "3.11", "3.12", "pypy3.9", "pypy3.10" ]
|
|
|
117
115
|
[tool.hatch.envs.typing]
|
|
118
116
|
detached = true
|
|
119
117
|
dependencies = [
|
|
120
|
-
"mypy ~= 1.
|
|
118
|
+
"mypy ~= 1.13",
|
|
121
119
|
"httpx",
|
|
122
120
|
"pytest",
|
|
123
121
|
"pikepdf",
|
|
124
|
-
"pytest-httpx
|
|
122
|
+
"pytest-httpx ~= 0.35",
|
|
125
123
|
]
|
|
126
124
|
|
|
127
125
|
[tool.hatch.envs.typing.scripts]
|
|
@@ -168,7 +166,7 @@ deploy = [
|
|
|
168
166
|
#
|
|
169
167
|
|
|
170
168
|
[tool.ruff]
|
|
171
|
-
target-version = "
|
|
169
|
+
target-version = "py39"
|
|
172
170
|
line-length = 120
|
|
173
171
|
|
|
174
172
|
# https://docs.astral.sh/ruff/settings/
|
|
@@ -244,6 +242,7 @@ lint.ignore = [
|
|
|
244
242
|
]
|
|
245
243
|
# Tests can use magic values, assertions, and relative imports
|
|
246
244
|
lint.per-file-ignores."tests/**/*" = [ "PLR2004", "S101", "TID252" ]
|
|
245
|
+
lint.per-file-ignores."tests/utils.py" = [ "S603" ]
|
|
247
246
|
# No relative imports
|
|
248
247
|
lint.flake8-tidy-imports.ban-relative-imports = "all"
|
|
249
248
|
# One import per line
|
|
@@ -251,6 +250,9 @@ lint.isort.force-single-line = true
|
|
|
251
250
|
# Recognize us please
|
|
252
251
|
lint.isort.known-first-party = [ "gotenberg_client" ]
|
|
253
252
|
|
|
253
|
+
[tool.pyproject-fmt]
|
|
254
|
+
max_supported_python = "3.13"
|
|
255
|
+
|
|
254
256
|
[tool.pytest.ini_options]
|
|
255
257
|
minversion = "7.0"
|
|
256
258
|
testpaths = [ "tests" ]
|
|
@@ -4,15 +4,19 @@
|
|
|
4
4
|
from gotenberg_client._client import GotenbergClient
|
|
5
5
|
from gotenberg_client._errors import BaseClientError
|
|
6
6
|
from gotenberg_client._errors import CannotExtractHereError
|
|
7
|
+
from gotenberg_client._errors import InvalidKeywordError
|
|
8
|
+
from gotenberg_client._errors import InvalidPdfRevisionError
|
|
7
9
|
from gotenberg_client._errors import MaxRetriesExceededError
|
|
8
10
|
from gotenberg_client.responses import SingleFileResponse
|
|
9
11
|
from gotenberg_client.responses import ZipFileResponse
|
|
10
12
|
|
|
11
13
|
__all__ = [
|
|
12
|
-
"GotenbergClient",
|
|
13
|
-
"SingleFileResponse",
|
|
14
|
-
"ZipFileResponse",
|
|
15
14
|
"BaseClientError",
|
|
16
15
|
"CannotExtractHereError",
|
|
16
|
+
"GotenbergClient",
|
|
17
|
+
"InvalidKeywordError",
|
|
18
|
+
"InvalidPdfRevisionError",
|
|
17
19
|
"MaxRetriesExceededError",
|
|
20
|
+
"SingleFileResponse",
|
|
21
|
+
"ZipFileResponse",
|
|
18
22
|
]
|
|
@@ -6,10 +6,7 @@ from contextlib import ExitStack
|
|
|
6
6
|
from pathlib import Path
|
|
7
7
|
from time import sleep
|
|
8
8
|
from types import TracebackType
|
|
9
|
-
from typing import Dict
|
|
10
9
|
from typing import Optional
|
|
11
|
-
from typing import Tuple
|
|
12
|
-
from typing import Type
|
|
13
10
|
|
|
14
11
|
from httpx import Client
|
|
15
12
|
from httpx import HTTPStatusError
|
|
@@ -71,13 +68,13 @@ class _BaseRoute(PdfFormatMixin, PfdUniversalAccessMixin):
|
|
|
71
68
|
self._route = api_route
|
|
72
69
|
self._stack = ExitStack()
|
|
73
70
|
# These are the options that will be set to Gotenberg. Things like PDF/A
|
|
74
|
-
self._form_data:
|
|
71
|
+
self._form_data: dict[str, str] = {}
|
|
75
72
|
# These are the names of files, mapping to their Path
|
|
76
|
-
self._file_map:
|
|
73
|
+
self._file_map: dict[str, Path] = {}
|
|
77
74
|
# Additional in memory resources, mapping the referenced name to the content and an optional mimetype
|
|
78
|
-
self._in_memory_resources:
|
|
75
|
+
self._in_memory_resources: dict[str, tuple[str, Optional[str]]] = {}
|
|
79
76
|
# Any header that will also be sent
|
|
80
|
-
self._headers:
|
|
77
|
+
self._headers: dict[str, str] = {}
|
|
81
78
|
|
|
82
79
|
def __enter__(self) -> Self:
|
|
83
80
|
self.reset()
|
|
@@ -85,7 +82,7 @@ class _BaseRoute(PdfFormatMixin, PfdUniversalAccessMixin):
|
|
|
85
82
|
|
|
86
83
|
def __exit__(
|
|
87
84
|
self,
|
|
88
|
-
exc_type: Optional[
|
|
85
|
+
exc_type: Optional[type[BaseException]],
|
|
89
86
|
exc_val: Optional[BaseException],
|
|
90
87
|
exc_tb: Optional[TracebackType],
|
|
91
88
|
) -> None:
|
|
@@ -111,6 +108,7 @@ class _BaseRoute(PdfFormatMixin, PfdUniversalAccessMixin):
|
|
|
111
108
|
Executes the configured route against the server and returns the resulting
|
|
112
109
|
Response.
|
|
113
110
|
"""
|
|
111
|
+
|
|
114
112
|
resp = self._client.post(
|
|
115
113
|
url=self._route,
|
|
116
114
|
headers=self._headers,
|
|
@@ -3,9 +3,7 @@
|
|
|
3
3
|
# SPDX-License-Identifier: MPL-2.0
|
|
4
4
|
import logging
|
|
5
5
|
from types import TracebackType
|
|
6
|
-
from typing import Dict
|
|
7
6
|
from typing import Optional
|
|
8
|
-
from typing import Type
|
|
9
7
|
|
|
10
8
|
from httpx import Client
|
|
11
9
|
|
|
@@ -65,7 +63,7 @@ class GotenbergClient:
|
|
|
65
63
|
self.merge = MergeApi(self._client)
|
|
66
64
|
self.health = HealthCheckApi(self._client)
|
|
67
65
|
|
|
68
|
-
def add_headers(self, header:
|
|
66
|
+
def add_headers(self, header: dict[str, str]) -> None:
|
|
69
67
|
"""
|
|
70
68
|
Update the httpx Client headers with the given values.
|
|
71
69
|
|
|
@@ -110,7 +108,7 @@ class GotenbergClient:
|
|
|
110
108
|
"""
|
|
111
109
|
self.add_headers({"Gotenberg-Webhook-Error-Method": method})
|
|
112
110
|
|
|
113
|
-
def set_webhook_extra_headers(self, extra_headers:
|
|
111
|
+
def set_webhook_extra_headers(self, extra_headers: dict[str, str]) -> None:
|
|
114
112
|
"""
|
|
115
113
|
Set additional HTTP headers for Gotenberg to use when calling webhooks.
|
|
116
114
|
|
|
@@ -138,7 +136,7 @@ class GotenbergClient:
|
|
|
138
136
|
|
|
139
137
|
def __exit__(
|
|
140
138
|
self,
|
|
141
|
-
exc_type: Optional[
|
|
139
|
+
exc_type: Optional[type[BaseException]],
|
|
142
140
|
exc_val: Optional[BaseException],
|
|
143
141
|
exc_tb: Optional[TracebackType],
|
|
144
142
|
) -> None:
|
|
@@ -3,10 +3,8 @@
|
|
|
3
3
|
# SPDX-License-Identifier: MPL-2.0
|
|
4
4
|
import logging
|
|
5
5
|
from pathlib import Path
|
|
6
|
-
from typing import List
|
|
7
6
|
from typing import Literal
|
|
8
7
|
from typing import Optional
|
|
9
|
-
from typing import Tuple
|
|
10
8
|
|
|
11
9
|
from httpx import Client
|
|
12
10
|
|
|
@@ -17,6 +15,7 @@ from gotenberg_client._convert.common import CustomHTTPHeaderMixin
|
|
|
17
15
|
from gotenberg_client._convert.common import EmulatedMediaMixin
|
|
18
16
|
from gotenberg_client._convert.common import HeaderFooterMixin
|
|
19
17
|
from gotenberg_client._convert.common import InvalidStatusCodesMixin
|
|
18
|
+
from gotenberg_client._convert.common import MetadataMixin
|
|
20
19
|
from gotenberg_client._convert.common import PageOrientMixin
|
|
21
20
|
from gotenberg_client._convert.common import PagePropertiesMixin
|
|
22
21
|
from gotenberg_client._convert.common import PerformanceModeMixin
|
|
@@ -82,7 +81,7 @@ class _RouteWithResources(BaseSingleFileResponseRoute):
|
|
|
82
81
|
self._add_in_memory_file(resource, name=name, mime_type=mime_type)
|
|
83
82
|
return self
|
|
84
83
|
|
|
85
|
-
def resources(self, resources:
|
|
84
|
+
def resources(self, resources: list[Path]) -> Self:
|
|
86
85
|
"""
|
|
87
86
|
Adds multiple resource files for the index HTML file to reference.
|
|
88
87
|
|
|
@@ -94,7 +93,7 @@ class _RouteWithResources(BaseSingleFileResponseRoute):
|
|
|
94
93
|
|
|
95
94
|
def string_resources(
|
|
96
95
|
self,
|
|
97
|
-
resources:
|
|
96
|
+
resources: list[tuple[str, str, Optional[str]]],
|
|
98
97
|
) -> Self:
|
|
99
98
|
"""
|
|
100
99
|
Process string resources.
|
|
@@ -125,6 +124,7 @@ class HtmlRoute(
|
|
|
125
124
|
HeaderFooterMixin,
|
|
126
125
|
RenderControlMixin,
|
|
127
126
|
PageOrientMixin,
|
|
127
|
+
MetadataMixin,
|
|
128
128
|
_RouteWithResources,
|
|
129
129
|
_FileBasedRoute,
|
|
130
130
|
):
|
|
@@ -141,6 +141,7 @@ class UrlRoute(
|
|
|
141
141
|
EmulatedMediaMixin,
|
|
142
142
|
CustomHTTPHeaderMixin,
|
|
143
143
|
PageOrientMixin,
|
|
144
|
+
MetadataMixin,
|
|
144
145
|
BaseSingleFileResponseRoute,
|
|
145
146
|
):
|
|
146
147
|
"""
|
|
@@ -183,7 +184,7 @@ class UrlRoute(
|
|
|
183
184
|
return FORCE_MULTIPART
|
|
184
185
|
|
|
185
186
|
|
|
186
|
-
class MarkdownRoute(PagePropertiesMixin, HeaderFooterMixin, _RouteWithResources, _FileBasedRoute):
|
|
187
|
+
class MarkdownRoute(PagePropertiesMixin, HeaderFooterMixin, MetadataMixin, _RouteWithResources, _FileBasedRoute):
|
|
187
188
|
"""
|
|
188
189
|
Represents the Gotenberg route for converting Markdown files to a PDF.
|
|
189
190
|
|
|
@@ -212,7 +213,7 @@ class MarkdownRoute(PagePropertiesMixin, HeaderFooterMixin, _RouteWithResources,
|
|
|
212
213
|
|
|
213
214
|
return self
|
|
214
215
|
|
|
215
|
-
def markdown_files(self, markdown_files:
|
|
216
|
+
def markdown_files(self, markdown_files: list[Path]) -> Self:
|
|
216
217
|
"""
|
|
217
218
|
Adds multiple Markdown files to be converted.
|
|
218
219
|
|