gotenberg-client 0.3.0__tar.gz → 0.4.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.
Files changed (54) hide show
  1. gotenberg_client-0.4.1/.gitignore +30 -0
  2. {gotenberg_client-0.3.0 → gotenberg_client-0.4.1}/.pre-commit-config.yaml +3 -3
  3. {gotenberg_client-0.3.0 → gotenberg_client-0.4.1}/CHANGELOG.md +26 -0
  4. {gotenberg_client-0.3.0 → gotenberg_client-0.4.1}/PKG-INFO +4 -3
  5. {gotenberg_client-0.3.0 → gotenberg_client-0.4.1}/README.md +1 -1
  6. {gotenberg_client-0.3.0 → gotenberg_client-0.4.1}/pyproject.toml +13 -8
  7. {gotenberg_client-0.3.0 → gotenberg_client-0.4.1}/src/gotenberg_client/__about__.py +1 -1
  8. {gotenberg_client-0.3.0 → gotenberg_client-0.4.1}/src/gotenberg_client/_base.py +28 -5
  9. {gotenberg_client-0.3.0 → gotenberg_client-0.4.1}/src/gotenberg_client/_client.py +2 -1
  10. {gotenberg_client-0.3.0 → gotenberg_client-0.4.1}/src/gotenberg_client/_convert/chromium.py +1 -1
  11. {gotenberg_client-0.3.0 → gotenberg_client-0.4.1}/src/gotenberg_client/_convert/common.py +1 -1
  12. {gotenberg_client-0.3.0 → gotenberg_client-0.4.1}/src/gotenberg_client/_convert/libre_office.py +1 -1
  13. {gotenberg_client-0.3.0 → gotenberg_client-0.4.1}/src/gotenberg_client/_convert/pdfa.py +1 -1
  14. {gotenberg_client-0.3.0 → gotenberg_client-0.4.1}/src/gotenberg_client/_health.py +2 -2
  15. {gotenberg_client-0.3.0 → gotenberg_client-0.4.1}/src/gotenberg_client/options.py +6 -3
  16. {gotenberg_client-0.3.0 → gotenberg_client-0.4.1}/tests/test_health.py +3 -2
  17. {gotenberg_client-0.3.0 → gotenberg_client-0.4.1}/tests/test_merge.py +3 -3
  18. {gotenberg_client-0.3.0 → gotenberg_client-0.4.1}/tests/test_misc_stuff.py +24 -0
  19. gotenberg_client-0.3.0/.gitignore +0 -163
  20. {gotenberg_client-0.3.0 → gotenberg_client-0.4.1}/.codecov.yml +0 -0
  21. {gotenberg_client-0.3.0 → gotenberg_client-0.4.1}/.editorconfig +0 -0
  22. {gotenberg_client-0.3.0 → gotenberg_client-0.4.1}/LICENSE +0 -0
  23. {gotenberg_client-0.3.0 → gotenberg_client-0.4.1}/src/gotenberg_client/__init__.py +0 -0
  24. {gotenberg_client-0.3.0 → gotenberg_client-0.4.1}/src/gotenberg_client/_convert/__init__.py +0 -0
  25. {gotenberg_client-0.3.0 → gotenberg_client-0.4.1}/src/gotenberg_client/_merge.py +0 -0
  26. {gotenberg_client-0.3.0 → gotenberg_client-0.4.1}/src/gotenberg_client/_metrics.py +0 -0
  27. /gotenberg_client-0.3.0/src/gotenberg_client/_types_compat.py → /gotenberg_client-0.4.1/src/gotenberg_client/_typing_compat.py +0 -0
  28. {gotenberg_client-0.3.0 → gotenberg_client-0.4.1}/src/gotenberg_client/_utils.py +0 -0
  29. {gotenberg_client-0.3.0 → gotenberg_client-0.4.1}/src/gotenberg_client/py.typed +0 -0
  30. {gotenberg_client-0.3.0 → gotenberg_client-0.4.1}/tests/__init__.py +0 -0
  31. {gotenberg_client-0.3.0 → gotenberg_client-0.4.1}/tests/conftest.py +0 -0
  32. {gotenberg_client-0.3.0 → gotenberg_client-0.4.1}/tests/samples/a_merge_second.pdf +0 -0
  33. {gotenberg_client-0.3.0 → gotenberg_client-0.4.1}/tests/samples/basic.html +0 -0
  34. {gotenberg_client-0.3.0 → gotenberg_client-0.4.1}/tests/samples/complex.html +0 -0
  35. {gotenberg_client-0.3.0 → gotenberg_client-0.4.1}/tests/samples/font.woff +0 -0
  36. {gotenberg_client-0.3.0 → gotenberg_client-0.4.1}/tests/samples/footer.html +0 -0
  37. {gotenberg_client-0.3.0 → gotenberg_client-0.4.1}/tests/samples/header.html +0 -0
  38. {gotenberg_client-0.3.0 → gotenberg_client-0.4.1}/tests/samples/img.gif +0 -0
  39. {gotenberg_client-0.3.0 → gotenberg_client-0.4.1}/tests/samples/markdown1.md +0 -0
  40. {gotenberg_client-0.3.0 → gotenberg_client-0.4.1}/tests/samples/markdown2.md +0 -0
  41. {gotenberg_client-0.3.0 → gotenberg_client-0.4.1}/tests/samples/markdown_index.html +0 -0
  42. {gotenberg_client-0.3.0 → gotenberg_client-0.4.1}/tests/samples/sample.docx +0 -0
  43. {gotenberg_client-0.3.0 → gotenberg_client-0.4.1}/tests/samples/sample.ods +0 -0
  44. {gotenberg_client-0.3.0 → gotenberg_client-0.4.1}/tests/samples/sample.odt +0 -0
  45. {gotenberg_client-0.3.0 → gotenberg_client-0.4.1}/tests/samples/sample.xlsx +0 -0
  46. {gotenberg_client-0.3.0 → gotenberg_client-0.4.1}/tests/samples/sample1.pdf +0 -0
  47. {gotenberg_client-0.3.0 → gotenberg_client-0.4.1}/tests/samples/style.css +0 -0
  48. {gotenberg_client-0.3.0 → gotenberg_client-0.4.1}/tests/samples/z_first_merge.pdf +0 -0
  49. {gotenberg_client-0.3.0 → gotenberg_client-0.4.1}/tests/test_convert_chromium_html.py +0 -0
  50. {gotenberg_client-0.3.0 → gotenberg_client-0.4.1}/tests/test_convert_chromium_markdown.py +0 -0
  51. {gotenberg_client-0.3.0 → gotenberg_client-0.4.1}/tests/test_convert_chromium_url.py +0 -0
  52. {gotenberg_client-0.3.0 → gotenberg_client-0.4.1}/tests/test_convert_libre_office.py +0 -0
  53. {gotenberg_client-0.3.0 → gotenberg_client-0.4.1}/tests/test_convert_pdf_a.py +0 -0
  54. {gotenberg_client-0.3.0 → gotenberg_client-0.4.1}/tests/utils.py +0 -0
@@ -0,0 +1,30 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+
5
+ # Ruff cache
6
+ .ruff_cache/
7
+
8
+ # Distribution / packaging
9
+ dist/
10
+
11
+ # Unit test / coverage reports
12
+ htmlcov/
13
+ .coverage
14
+ .coverage.*
15
+ .pytest_cache/
16
+ coverage.xml
17
+ coverage.json
18
+
19
+
20
+ # Environments
21
+ .env
22
+ .venv
23
+ env/
24
+ venv/
25
+
26
+ # mypy
27
+ .mypy_cache/
28
+
29
+ # Possible PDF generated from testing
30
+ tests/outputs/**
@@ -27,7 +27,7 @@ repos:
27
27
  - id: check-case-conflict
28
28
  - id: detect-private-key
29
29
  - repo: https://github.com/pre-commit/mirrors-prettier
30
- rev: 'v3.0.3'
30
+ rev: 'v3.1.0'
31
31
  hooks:
32
32
  - id: prettier
33
33
  types_or:
@@ -37,10 +37,10 @@ repos:
37
37
  exclude: "(^Pipfile\\.lock$)"
38
38
  # Python hooks
39
39
  - repo: https://github.com/astral-sh/ruff-pre-commit
40
- rev: 'v0.1.0'
40
+ rev: 'v0.1.6'
41
41
  hooks:
42
42
  - id: ruff
43
43
  - repo: https://github.com/psf/black
44
- rev: 23.10.0
44
+ rev: 23.11.0
45
45
  hooks:
46
46
  - id: black
@@ -5,6 +5,32 @@ 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.4.1] - 2023-12-11
9
+
10
+ ### Fixed
11
+
12
+ - Implemented an internal workaround for older Gotenberg versions and their handling of non-latin filenames.
13
+ - When detected, the files will be copied into a temporary directory and the filename cleaned
14
+ - Gotenberg 8.0.0 will start implementing something similar once released
15
+ - The pulled Gotenberg image is now inspected, allowing local re-creation of failures against specific digests
16
+ - The `:edge` tag testing is now allowed to fail
17
+
18
+ ## [0.4.0] - 2023-12-04
19
+
20
+ ### Changed
21
+
22
+ - Removed some certain special cases from coverage
23
+ - Updated `pre-commit` hook versions
24
+ - Updated how pytest is configured, so it will apply to any invocation
25
+ - Updated test running image to log at warning or lower using text format
26
+ - Updated test running image from 7.9.2 to 7.10.1
27
+ - For the moment, send both `pdfa` and `pdfFormat` for compatibility with 7.9 and 7.10
28
+ - See [here](https://github.com/stumpylog/gotenberg-client/issues/5#issuecomment-1839081129) for some subtle differences in what these options mean
29
+
30
+ ### Added
31
+
32
+ - Added new test job against Gotenberg's `:edge` tag
33
+
8
34
  ## [0.3.0] - 2023-10-17
9
35
 
10
36
  ### Added
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: gotenberg-client
3
- Version: 0.3.0
3
+ Version: 0.4.1
4
4
  Summary: A Python client for interfacing with the Gotenberg API
5
5
  Project-URL: Documentation, https://github.com/stumpylog/gotenberg-client/#readme
6
6
  Project-URL: Issues, https://github.com/stumpylog/gotenberg-client/issues
@@ -23,7 +23,8 @@ Classifier: Programming Language :: Python :: 3.12
23
23
  Classifier: Programming Language :: Python :: Implementation :: CPython
24
24
  Classifier: Programming Language :: Python :: Implementation :: PyPy
25
25
  Requires-Python: >=3.8
26
- Requires-Dist: httpx[http2]~=0.24
26
+ Requires-Dist: httpx[http2]~=0.24; python_version < '3.9'
27
+ Requires-Dist: httpx[http2]~=0.25; python_version >= '3.9'
27
28
  Requires-Dist: typing-extensions; python_version < '3.11'
28
29
  Provides-Extra: magic
29
30
  Requires-Dist: python-magic; extra == 'magic'
@@ -68,7 +69,7 @@ As far as I can tell, no active Python library exists to interface with the Gote
68
69
  - HTTP/2 enabled by default
69
70
  - Abstract away the handling of multi-part/form-data and deal with `Path`s instead
70
71
  - Based on the modern [httpx](https://github.com/encode/httpx) library
71
- - Full support for type hinting and concrete return types as mush as possible
72
+ - Full support for type hinting and concrete return types as much as possible
72
73
  - Nearly full test coverage run against an actual Gotenberg server for multiple Python and PyPy versions
73
74
 
74
75
  ## How
@@ -37,7 +37,7 @@ As far as I can tell, no active Python library exists to interface with the Gote
37
37
  - HTTP/2 enabled by default
38
38
  - Abstract away the handling of multi-part/form-data and deal with `Path`s instead
39
39
  - Based on the modern [httpx](https://github.com/encode/httpx) library
40
- - Full support for type hinting and concrete return types as mush as possible
40
+ - Full support for type hinting and concrete return types as much as possible
41
41
  - Nearly full test coverage run against an actual Gotenberg server for multiple Python and PyPy versions
42
42
 
43
43
  ## How
@@ -28,9 +28,10 @@ classifiers = [
28
28
  "Programming Language :: Python :: Implementation :: PyPy",
29
29
  ]
30
30
  dependencies = [
31
- "httpx[http2] ~= 0.24",
31
+ "httpx[http2] ~= 0.25; python_version >= '3.9'",
32
+ "httpx[http2] ~= 0.24; python_version < '3.9'",
32
33
  "typing-extensions; python_version < '3.11'"
33
- ]
34
+ ]
34
35
 
35
36
  [project.urls]
36
37
  Documentation = "https://github.com/stumpylog/gotenberg-client/#readme"
@@ -64,8 +65,8 @@ dependencies = [
64
65
  [tool.hatch.envs.default.scripts]
65
66
  version = "python3 --version"
66
67
  pip-list = "pip list"
67
- test = "pytest --pythonwarnings=all {args:tests}"
68
- test-cov = "coverage run -m pytest --pythonwarnings=all {args:tests}"
68
+ test = "pytest {args:tests}"
69
+ test-cov = "coverage run -m pytest {args:tests}"
69
70
  cov-clear = "coverage erase"
70
71
  cov-report = [
71
72
  "- coverage combine",
@@ -83,10 +84,9 @@ cov = [
83
84
  "cov-html"
84
85
  ]
85
86
 
86
- [[tool.hatch.envs.all.matrix]]
87
- python = ["3.8", "3.9", "3.10", "3.11", "3.12"]
88
-
89
87
  [tool.hatch.envs.pre-commit]
88
+ template = "pre-commit"
89
+ detached = true
90
90
  dependencies = [
91
91
  "pre-commit>=3.5.0",
92
92
  ]
@@ -207,6 +207,11 @@ ban-relative-imports = "all"
207
207
  # Tests can use magic values, assertions, and relative imports
208
208
  "tests/**/*" = ["PLR2004", "S101", "TID252"]
209
209
 
210
+ [tool.pytest.ini_options]
211
+ minversion = "7.0"
212
+ testpaths = ["tests"]
213
+ addopts = "--pythonwarnings=all"
214
+
210
215
  [tool.coverage.run]
211
216
  source_pkgs = ["gotenberg_client", "tests"]
212
217
  branch = true
@@ -235,7 +240,7 @@ exclude = [
235
240
  "tests/test_convert_chromium_url.py",
236
241
  "tests/test_convert_chromium_markdown.py",
237
242
  "tests/conftest.py",
238
- ]
243
+ ]
239
244
  disallow_any_expr = true
240
245
  disallow_untyped_defs = true
241
246
  disallow_incomplete_defs = true
@@ -1,4 +1,4 @@
1
1
  # SPDX-FileCopyrightText: 2023-present Trenton H <rda0128ou@mozmail.com>
2
2
  #
3
3
  # SPDX-License-Identifier: MPL-2.0
4
- __version__ = "0.3.0"
4
+ __version__ = "0.4.1"
@@ -4,6 +4,7 @@
4
4
  import logging
5
5
  from contextlib import ExitStack
6
6
  from pathlib import Path
7
+ from tempfile import TemporaryDirectory
7
8
  from types import TracebackType
8
9
  from typing import Dict
9
10
  from typing import Optional
@@ -13,7 +14,7 @@ from httpx import Client
13
14
  from httpx import Response
14
15
  from httpx._types import RequestFiles
15
16
 
16
- from gotenberg_client._types_compat import Self
17
+ from gotenberg_client._typing_compat import Self
17
18
  from gotenberg_client._utils import guess_mime_type
18
19
  from gotenberg_client.options import PdfAFormat
19
20
 
@@ -30,8 +31,11 @@ class BaseRoute:
30
31
  self._client = client
31
32
  self._route = api_route
32
33
  self._stack = ExitStack()
34
+ # These are the options that will be set to Gotenberg. Things like PDF/A
33
35
  self._form_data: Dict[str, str] = {}
36
+ # These are the names of files, mapping to their Path
34
37
  self._file_map: Dict[str, Path] = {}
38
+ # Any header that will also be sent
35
39
  self._headers: Dict[str, str] = {}
36
40
 
37
41
  def __enter__(self) -> Self:
@@ -44,7 +48,7 @@ class BaseRoute:
44
48
  exc_val: Optional[BaseException],
45
49
  exc_tb: Optional[TracebackType],
46
50
  ) -> None:
47
- self.reset()
51
+ self.close()
48
52
 
49
53
  def reset(self) -> None:
50
54
  """
@@ -99,11 +103,26 @@ class BaseRoute:
99
103
  """
100
104
  if name is None:
101
105
  name = filepath.name
106
+
102
107
  if name in self._file_map: # pragma: no cover
103
108
  logger.warning(f"{name} has already been provided, overwriting anyway")
109
+
110
+ try:
111
+ name.encode("utf8").decode("ascii")
112
+ except UnicodeDecodeError:
113
+ logger.warning(f"filename {name} includes non-ascii characters, compensating for Gotenberg")
114
+ tmp_dir = self._stack.enter_context(TemporaryDirectory())
115
+ # Filename can be fixed, the directory is random
116
+ new_path = Path(tmp_dir) / Path(name).with_name(f"clean-filename-copy{filepath.suffix}")
117
+ logger.warning(f"New path {new_path}")
118
+ new_path.write_bytes(filepath.read_bytes())
119
+ filepath = new_path
120
+ name = new_path.name
121
+ logger.warning(f"New name {name}")
122
+
104
123
  self._file_map[name] = filepath
105
124
 
106
- def pdf_format(self, pdf_format: PdfAFormat) -> "BaseRoute":
125
+ def pdf_format(self, pdf_format: PdfAFormat) -> Self:
107
126
  """
108
127
  All routes provide the option to configure the output PDF as a
109
128
  PDF/A format
@@ -111,11 +130,15 @@ class BaseRoute:
111
130
  self._form_data.update(pdf_format.to_form())
112
131
  return self
113
132
 
114
- def trace(self, trace_id: str) -> "BaseRoute":
133
+ def universal_access_pdf(self, *, pdf_ua: bool) -> Self:
134
+ self._form_data.update({"pdfua": str(pdf_ua).lower()})
135
+ return self
136
+
137
+ def trace(self, trace_id: str) -> Self:
115
138
  self._headers["Gotenberg-Trace"] = trace_id
116
139
  return self
117
140
 
118
- def output_name(self, filename: str) -> "BaseRoute":
141
+ def output_name(self, filename: str) -> Self:
119
142
  self._headers["Gotenberg-Output-Filename"] = filename
120
143
  return self
121
144
 
@@ -14,6 +14,7 @@ from gotenberg_client._convert.libre_office import LibreOfficeApi
14
14
  from gotenberg_client._convert.pdfa import PdfAApi
15
15
  from gotenberg_client._health import HealthCheckApi
16
16
  from gotenberg_client._merge import MergeApi
17
+ from gotenberg_client._typing_compat import Self
17
18
 
18
19
 
19
20
  class GotenbergClient:
@@ -49,7 +50,7 @@ class GotenbergClient:
49
50
  """
50
51
  self._client.headers.update(header)
51
52
 
52
- def __enter__(self) -> "GotenbergClient":
53
+ def __enter__(self) -> Self:
53
54
  return self
54
55
 
55
56
  def close(self) -> None:
@@ -11,7 +11,7 @@ from typing import Union
11
11
 
12
12
  from gotenberg_client._base import BaseApi
13
13
  from gotenberg_client._convert.common import ConvertBaseRoute
14
- from gotenberg_client._types_compat import Self
14
+ from gotenberg_client._typing_compat import Self
15
15
  from gotenberg_client.options import EmulatedMediaType
16
16
  from gotenberg_client.options import Margin
17
17
  from gotenberg_client.options import PageSize
@@ -4,7 +4,7 @@
4
4
  import logging
5
5
 
6
6
  from gotenberg_client._base import BaseRoute
7
- from gotenberg_client._types_compat import Self
7
+ from gotenberg_client._typing_compat import Self
8
8
  from gotenberg_client.options import PageOrientation
9
9
 
10
10
  logger = logging.getLogger()
@@ -6,7 +6,7 @@ from typing import List
6
6
 
7
7
  from gotenberg_client._base import BaseApi
8
8
  from gotenberg_client._convert.common import ConvertBaseRoute
9
- from gotenberg_client._types_compat import Self
9
+ from gotenberg_client._typing_compat import Self
10
10
 
11
11
 
12
12
  class LibreOfficeConvertRoute(ConvertBaseRoute):
@@ -6,7 +6,7 @@ from typing import List
6
6
 
7
7
  from gotenberg_client._base import BaseApi
8
8
  from gotenberg_client._convert.common import ConvertBaseRoute
9
- from gotenberg_client._types_compat import Self
9
+ from gotenberg_client._typing_compat import Self
10
10
 
11
11
 
12
12
  class PdfAConvertRoute(ConvertBaseRoute):
@@ -86,7 +86,7 @@ class HealthStatus:
86
86
  @no_type_check
87
87
  def _extract_datetime(timestamp: str) -> datetime.datetime:
88
88
  m = _TIME_RE.match(timestamp)
89
- if not m:
89
+ if not m: # pragma: no cover
90
90
  msg = f"Unable to parse {timestamp}"
91
91
  raise ValueError(msg)
92
92
 
@@ -97,7 +97,7 @@ class HealthStatus:
97
97
  if timezone_str is not None:
98
98
  if timezone_str.lower() == "z":
99
99
  tzinfo = datetime.timezone.utc
100
- else:
100
+ else: # pragma: no cover
101
101
  multi = -1 if timezone_str[0:1] == "-" else 1
102
102
  hours = int(timezone_str[1:3])
103
103
  minutes = int(timezone_str[4:])
@@ -18,12 +18,15 @@ class PdfAFormat(enum.Enum):
18
18
  A3b = enum.auto()
19
19
 
20
20
  def to_form(self) -> Dict[str, str]:
21
+ format_name = None
21
22
  if self.value == PdfAFormat.A1a.value:
22
- return {"pdfFormat": "PDF/A-1a"}
23
+ format_name = "PDF/A-1a"
23
24
  elif self.value == PdfAFormat.A2b.value:
24
- return {"pdfFormat": "PDF/A-2b"}
25
+ format_name = "PDF/A-2b"
25
26
  elif self.value == PdfAFormat.A3b.value:
26
- return {"pdfFormat": "PDF/A-3b"}
27
+ format_name = "PDF/A-3b"
28
+ if format_name is not None:
29
+ return {"pdfa": format_name, "pdfFormat": format_name}
27
30
  else: # pragma: no cover
28
31
  raise NotImplementedError(self.value)
29
32
 
@@ -11,5 +11,6 @@ class TestHealthStatus:
11
11
  assert status.overall == StatusOptions.Up
12
12
  assert status.chromium is not None
13
13
  assert status.chromium.status == StatusOptions.Up
14
- assert status.uno is not None
15
- assert status.uno.status == StatusOptions.Up
14
+ if "uno" in status.data:
15
+ assert status.uno is not None
16
+ assert status.uno.status == StatusOptions.Up
@@ -51,11 +51,11 @@ class TestMergePdfs:
51
51
  self,
52
52
  client: GotenbergClient,
53
53
  ):
54
- if shutil.which("pdftotext") is None:
54
+ if shutil.which("pdftotext") is None: # pragma: no cover
55
55
  pytest.skip("No pdftotext executable found")
56
56
  else:
57
57
  with client.merge.merge() as route:
58
- # By default, these would not merge correctly
58
+ # By default, these would not merge correctly, as it happens alphabetically
59
59
  route.merge([SAMPLE_DIR / "z_first_merge.pdf", SAMPLE_DIR / "a_merge_second.pdf"])
60
60
  resp = call_run_with_server_error_handling(route)
61
61
 
@@ -66,7 +66,7 @@ class TestMergePdfs:
66
66
  with tempfile.NamedTemporaryFile(mode="wb") as tmp:
67
67
  tmp.write(resp.content)
68
68
 
69
- text = extract_text(tmp.name)
69
+ text = extract_text(Path(tmp.name))
70
70
  lines = text.split("\n")
71
71
  # Extra is empty line
72
72
  assert len(lines) == 3
@@ -1,4 +1,7 @@
1
+ import shutil
2
+ import tempfile
1
3
  import uuid
4
+ from pathlib import Path
2
5
 
3
6
  from httpx import codes
4
7
 
@@ -43,3 +46,24 @@ class TestMiscFunctionality:
43
46
  assert resp.headers["Content-Type"] == "application/pdf"
44
47
  assert "Content-Disposition" in resp.headers
45
48
  assert f"{filename}.pdf" in resp.headers["Content-Disposition"]
49
+
50
+ def test_libre_office_convert_cyrillic(self, client: GotenbergClient):
51
+ """
52
+ Gotenberg versions before 8.0.0 could not internally handle filenames with
53
+ non-ASCII characters. This replicates such a thing against 1 endpoint to
54
+ verify the workaround inside this library
55
+ """
56
+ test_file = SAMPLE_DIR / "sample.odt"
57
+
58
+ with tempfile.TemporaryDirectory() as temp_dir:
59
+ copy = shutil.copy(
60
+ test_file,
61
+ Path(temp_dir) / "Карточка партнера Тауберг Альфа.odt", # noqa: RUF001
62
+ )
63
+
64
+ with client.libre_office.to_pdf() as route:
65
+ resp = call_run_with_server_error_handling(route.convert(copy))
66
+
67
+ assert resp.status_code == codes.OK
68
+ assert "Content-Type" in resp.headers
69
+ assert resp.headers["Content-Type"] == "application/pdf"
@@ -1,163 +0,0 @@
1
- # Byte-compiled / optimized / DLL files
2
- __pycache__/
3
- *.py[cod]
4
- *$py.class
5
-
6
- # C extensions
7
- *.so
8
-
9
- # Distribution / packaging
10
- .Python
11
- build/
12
- develop-eggs/
13
- dist/
14
- downloads/
15
- eggs/
16
- .eggs/
17
- lib/
18
- lib64/
19
- parts/
20
- sdist/
21
- var/
22
- wheels/
23
- share/python-wheels/
24
- *.egg-info/
25
- .installed.cfg
26
- *.egg
27
- MANIFEST
28
-
29
- # PyInstaller
30
- # Usually these files are written by a python script from a template
31
- # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
- *.manifest
33
- *.spec
34
-
35
- # Installer logs
36
- pip-log.txt
37
- pip-delete-this-directory.txt
38
-
39
- # Unit test / coverage reports
40
- htmlcov/
41
- .tox/
42
- .nox/
43
- .coverage
44
- .coverage.*
45
- .cache
46
- nosetests.xml
47
- coverage.xml
48
- *.cover
49
- *.py,cover
50
- .hypothesis/
51
- .pytest_cache/
52
- cover/
53
- coverage.json
54
-
55
- # Translations
56
- *.mo
57
- *.pot
58
-
59
- # Django stuff:
60
- *.log
61
- local_settings.py
62
- db.sqlite3
63
- db.sqlite3-journal
64
-
65
- # Flask stuff:
66
- instance/
67
- .webassets-cache
68
-
69
- # Scrapy stuff:
70
- .scrapy
71
-
72
- # Sphinx documentation
73
- docs/_build/
74
-
75
- # PyBuilder
76
- .pybuilder/
77
- target/
78
-
79
- # Jupyter Notebook
80
- .ipynb_checkpoints
81
-
82
- # IPython
83
- profile_default/
84
- ipython_config.py
85
-
86
- # pyenv
87
- # For a library or package, you might want to ignore these files since the code is
88
- # intended to run in multiple environments; otherwise, check them in:
89
- # .python-version
90
-
91
- # pipenv
92
- # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
93
- # However, in case of collaboration, if having platform-specific dependencies or dependencies
94
- # having no cross-platform support, pipenv may install dependencies that don't work, or not
95
- # install all needed dependencies.
96
- #Pipfile.lock
97
-
98
- # poetry
99
- # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
100
- # This is especially recommended for binary packages to ensure reproducibility, and is more
101
- # commonly ignored for libraries.
102
- # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
103
- #poetry.lock
104
-
105
- # pdm
106
- # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
107
- #pdm.lock
108
- # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
109
- # in version control.
110
- # https://pdm.fming.dev/#use-with-ide
111
- .pdm.toml
112
-
113
- # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
114
- __pypackages__/
115
-
116
- # Celery stuff
117
- celerybeat-schedule
118
- celerybeat.pid
119
-
120
- # SageMath parsed files
121
- *.sage.py
122
-
123
- # Environments
124
- .env
125
- .venv
126
- env/
127
- venv/
128
- ENV/
129
- env.bak/
130
- venv.bak/
131
-
132
- # Spyder project settings
133
- .spyderproject
134
- .spyproject
135
-
136
- # Rope project settings
137
- .ropeproject
138
-
139
- # mkdocs documentation
140
- /site
141
-
142
- # mypy
143
- .mypy_cache/
144
- .dmypy.json
145
- dmypy.json
146
-
147
- # Pyre type checker
148
- .pyre/
149
-
150
- # pytype static type analyzer
151
- .pytype/
152
-
153
- # Cython debug symbols
154
- cython_debug/
155
-
156
- # PyCharm
157
- # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
158
- # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
159
- # and can be added to the global gitignore or merged into this file. For a more nuclear
160
- # option (not recommended) you can uncomment the following to ignore the entire idea folder.
161
- #.idea/
162
-
163
- tests/outputs/**