From eb638e3bf1a3e1ec2d17bcbb0dc7c9e536d01b9c Mon Sep 17 00:00:00 2001 From: Trenton H <797416+stumpylog@users.noreply.github.com> Date: Tue, 17 Oct 2023 20:16:59 -0700 Subject: [PATCH 1/9] Fix spelling in README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 60ecbde..fd6e2c1 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ As far as I can tell, no active Python library exists to interface with the Gote - HTTP/2 enabled by default - Abstract away the handling of multi-part/form-data and deal with `Path`s instead - Based on the modern [httpx](https://github.com/encode/httpx) library -- Full support for type hinting and concrete return types as mush as possible +- Full support for type hinting and concrete return types as much as possible - Nearly full test coverage run against an actual Gotenberg server for multiple Python and PyPy versions ## How From 9d17d5eca8a8450e68e83394f1688c6eb7731904 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 1 Nov 2023 11:10:36 +0000 Subject: [PATCH 2/9] Bump actions/checkout from 3 to 4 Bumps [actions/checkout](https://github.com/actions/checkout) from 3 to 4. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v3...v4) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/codeql.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index b8c211d..2a8e2c1 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -52,7 +52,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL From 530aa3958867803864e8eec82d384c3a34a0bcba Mon Sep 17 00:00:00 2001 From: Trenton Holmes <797416+stumpylog@users.noreply.github.com> Date: Mon, 13 Nov 2023 14:12:32 -0800 Subject: [PATCH 3/9] A few small updates as per the changelog --- .pre-commit-config.yaml | 6 +++--- CHANGELOG.md | 8 ++++++++ pyproject.toml | 16 +++++++++++----- src/gotenberg_client/_base.py | 11 +++++++---- src/gotenberg_client/_client.py | 3 ++- src/gotenberg_client/_health.py | 4 ++-- tests/test_merge.py | 6 +++--- 7 files changed, 36 insertions(+), 18 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a50d88d..6a4c9c1 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -27,7 +27,7 @@ repos: - id: check-case-conflict - id: detect-private-key - repo: https://github.com/pre-commit/mirrors-prettier - rev: 'v3.0.3' + rev: 'v3.1.0' hooks: - id: prettier types_or: @@ -37,10 +37,10 @@ repos: exclude: "(^Pipfile\\.lock$)" # Python hooks - repo: https://github.com/astral-sh/ruff-pre-commit - rev: 'v0.1.0' + rev: 'v0.1.5' hooks: - id: ruff - repo: https://github.com/psf/black - rev: 23.10.0 + rev: 23.11.0 hooks: - id: black diff --git a/CHANGELOG.md b/CHANGELOG.md index 016a814..f6bdb38 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [Unreleased] + +### Changed + +- Removed some certain special cases from coverage +- Updated `pre-commit` hook versions +- Updated how pytest is configured, so it will apply to any invocation + ## [0.3.0] - 2023-10-17 ### Added diff --git a/pyproject.toml b/pyproject.toml index 5434bf7..db81536 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -28,9 +28,10 @@ classifiers = [ "Programming Language :: Python :: Implementation :: PyPy", ] dependencies = [ - "httpx[http2] ~= 0.24", + "httpx[http2] ~= 0.25; python_version >= '3.9'", + "httpx[http2] ~= 0.24; python_version < '3.9'", "typing-extensions; python_version < '3.11'" - ] +] [project.urls] Documentation = "https://github.com/stumpylog/gotenberg-client/#readme" @@ -64,8 +65,8 @@ dependencies = [ [tool.hatch.envs.default.scripts] version = "python3 --version" pip-list = "pip list" -test = "pytest --pythonwarnings=all {args:tests}" -test-cov = "coverage run -m pytest --pythonwarnings=all {args:tests}" +test = "pytest {args:tests}" +test-cov = "coverage run -m pytest {args:tests}" cov-clear = "coverage erase" cov-report = [ "- coverage combine", @@ -207,6 +208,11 @@ ban-relative-imports = "all" # Tests can use magic values, assertions, and relative imports "tests/**/*" = ["PLR2004", "S101", "TID252"] +[tool.pytest.ini_options] +minversion = "7.0" +testpaths = ["tests"] +addopts = "--pythonwarnings=all" + [tool.coverage.run] source_pkgs = ["gotenberg_client", "tests"] branch = true @@ -235,7 +241,7 @@ exclude = [ "tests/test_convert_chromium_url.py", "tests/test_convert_chromium_markdown.py", "tests/conftest.py", - ] +] disallow_any_expr = true disallow_untyped_defs = true disallow_incomplete_defs = true diff --git a/src/gotenberg_client/_base.py b/src/gotenberg_client/_base.py index 1701039..42aa930 100644 --- a/src/gotenberg_client/_base.py +++ b/src/gotenberg_client/_base.py @@ -30,8 +30,11 @@ def __init__(self, client: Client, api_route: str) -> None: self._client = client self._route = api_route self._stack = ExitStack() + # These are the options that will be set to Gotenberg. Things like PDF/A self._form_data: Dict[str, str] = {} + # These are the names of files, mapping to their Path self._file_map: Dict[str, Path] = {} + # Any header that will also be sent self._headers: Dict[str, str] = {} def __enter__(self) -> Self: @@ -44,7 +47,7 @@ def __exit__( exc_val: Optional[BaseException], exc_tb: Optional[TracebackType], ) -> None: - self.reset() + self.close() def reset(self) -> None: """ @@ -103,7 +106,7 @@ def _add_file_map(self, filepath: Path, name: Optional[str] = None) -> None: logger.warning(f"{name} has already been provided, overwriting anyway") self._file_map[name] = filepath - def pdf_format(self, pdf_format: PdfAFormat) -> "BaseRoute": + def pdf_format(self, pdf_format: PdfAFormat) -> Self: """ All routes provide the option to configure the output PDF as a PDF/A format @@ -111,11 +114,11 @@ def pdf_format(self, pdf_format: PdfAFormat) -> "BaseRoute": self._form_data.update(pdf_format.to_form()) return self - def trace(self, trace_id: str) -> "BaseRoute": + def trace(self, trace_id: str) -> Self: self._headers["Gotenberg-Trace"] = trace_id return self - def output_name(self, filename: str) -> "BaseRoute": + def output_name(self, filename: str) -> Self: self._headers["Gotenberg-Output-Filename"] = filename return self diff --git a/src/gotenberg_client/_client.py b/src/gotenberg_client/_client.py index fc54e2e..9068dad 100644 --- a/src/gotenberg_client/_client.py +++ b/src/gotenberg_client/_client.py @@ -14,6 +14,7 @@ from gotenberg_client._convert.pdfa import PdfAApi from gotenberg_client._health import HealthCheckApi from gotenberg_client._merge import MergeApi +from gotenberg_client._types_compat import Self class GotenbergClient: @@ -49,7 +50,7 @@ def add_headers(self, header: Dict[str, str]) -> None: # pragma: no cover """ self._client.headers.update(header) - def __enter__(self) -> "GotenbergClient": + def __enter__(self) -> Self: return self def close(self) -> None: diff --git a/src/gotenberg_client/_health.py b/src/gotenberg_client/_health.py index 479ee74..3fd87ec 100644 --- a/src/gotenberg_client/_health.py +++ b/src/gotenberg_client/_health.py @@ -86,7 +86,7 @@ def _extract_status(self, module: ModuleOptions) -> ModuleStatus: @no_type_check def _extract_datetime(timestamp: str) -> datetime.datetime: m = _TIME_RE.match(timestamp) - if not m: + if not m: # pragma: no cover msg = f"Unable to parse {timestamp}" raise ValueError(msg) @@ -97,7 +97,7 @@ def _extract_datetime(timestamp: str) -> datetime.datetime: if timezone_str is not None: if timezone_str.lower() == "z": tzinfo = datetime.timezone.utc - else: + else: # pragma: no cover multi = -1 if timezone_str[0:1] == "-" else 1 hours = int(timezone_str[1:3]) minutes = int(timezone_str[4:]) diff --git a/tests/test_merge.py b/tests/test_merge.py index 49be37a..7b3187d 100644 --- a/tests/test_merge.py +++ b/tests/test_merge.py @@ -51,11 +51,11 @@ def test_merge_multiple_file( self, client: GotenbergClient, ): - if shutil.which("pdftotext") is None: + if shutil.which("pdftotext") is None: # pragma: no cover pytest.skip("No pdftotext executable found") else: with client.merge.merge() as route: - # By default, these would not merge correctly + # By default, these would not merge correctly, as it happens alphabetically route.merge([SAMPLE_DIR / "z_first_merge.pdf", SAMPLE_DIR / "a_merge_second.pdf"]) resp = call_run_with_server_error_handling(route) @@ -66,7 +66,7 @@ def test_merge_multiple_file( with tempfile.NamedTemporaryFile(mode="wb") as tmp: tmp.write(resp.content) - text = extract_text(tmp.name) + text = extract_text(Path(tmp.name)) lines = text.split("\n") # Extra is empty line assert len(lines) == 3 From 1f58a419d307b0342f5b6f4ca6fc51e24cc3f911 Mon Sep 17 00:00:00 2001 From: Trenton Holmes <797416+stumpylog@users.noreply.github.com> Date: Sun, 19 Nov 2023 16:58:33 -0800 Subject: [PATCH 4/9] Adds new test job against Gotenberg :edge tag --- .docker/docker-compose.ci-test-edge.yml | 12 +++++++ .github/workflows/ci.yml | 43 ++++++++++++++++++++++++- CHANGELOG.md | 4 +++ 3 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 .docker/docker-compose.ci-test-edge.yml diff --git a/.docker/docker-compose.ci-test-edge.yml b/.docker/docker-compose.ci-test-edge.yml new file mode 100644 index 0000000..df165b5 --- /dev/null +++ b/.docker/docker-compose.ci-test-edge.yml @@ -0,0 +1,12 @@ +# docker-compose file for running testing with gotenberg container +# Can be used locally or by the CI to start the nessecary container with the +# correct networking for the tests + +version: "3" +services: + gotenberg-client-test-server: + image: docker.io/gotenberg/gotenberg:edge + hostname: gotenberg-client-test-server + container_name: gotenberg-client-test-server + network_mode: host + restart: unless-stopped diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4f5e6da..241463a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -96,7 +96,48 @@ jobs: run: | docker compose --file ${GITHUB_WORKSPACE}/.docker/docker-compose.ci-test.yml logs docker compose --file ${GITHUB_WORKSPACE}/.docker/docker-compose.ci-test.yml down - + test-edge: + name: Test Gotenberg :edge + runs-on: ubuntu-latest + permissions: + contents: read + needs: + - lint + steps: + - + uses: actions/checkout@v4 + - + name: Start containers + run: | + docker compose --file ${GITHUB_WORKSPACE}/.docker/docker-compose.ci-test-edge.yml pull --quiet + docker compose --file ${GITHUB_WORKSPACE}/.docker/docker-compose.ci-test-edge.yml up --detach + echo "Wait for container to be started" + sleep 5 + - + name: Install poppler-utils + run: | + sudo apt-get update + sudo apt-get install --yes --no-install-recommends poppler-utils + - + name: Set up Python 3.11 + uses: actions/setup-python@v4 + with: + python-version: "3.11" + cache: 'pip' + - + name: Install Hatch + run: | + python3 -m pip install --upgrade pip + pip install --upgrade hatch + - + name: Run tests + run: hatch run cov + - + name: Stop containers + if: always() + run: | + docker compose --file ${GITHUB_WORKSPACE}/.docker/docker-compose.ci-test-edge.yml logs + docker compose --file ${GITHUB_WORKSPACE}/.docker/docker-compose.ci-test-edge.yml down build: name: Build runs-on: ubuntu-latest diff --git a/CHANGELOG.md b/CHANGELOG.md index f6bdb38..725a4d4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Updated `pre-commit` hook versions - Updated how pytest is configured, so it will apply to any invocation +### Added + +- Added new test job against Gotenberg's `:edge` tag + ## [0.3.0] - 2023-10-17 ### Added From e2d7866e3e4474cf2fdc9703b133a97f324406fc Mon Sep 17 00:00:00 2001 From: Trenton Holmes <797416+stumpylog@users.noreply.github.com> Date: Sun, 19 Nov 2023 17:15:16 -0800 Subject: [PATCH 5/9] Fixes a failure regarding uni status on :edge --- .gitignore | 141 ++-------------------------------------- .pre-commit-config.yaml | 2 +- pyproject.toml | 5 +- tests/test_health.py | 5 +- 4 files changed, 10 insertions(+), 143 deletions(-) diff --git a/.gitignore b/.gitignore index 97a31f3..79740f8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,163 +1,30 @@ # Byte-compiled / optimized / DLL files __pycache__/ *.py[cod] -*$py.class -# C extensions -*.so +# Ruff cache +.ruff_cache/ # Distribution / packaging -.Python -build/ -develop-eggs/ dist/ -downloads/ -eggs/ -.eggs/ -lib/ -lib64/ -parts/ -sdist/ -var/ -wheels/ -share/python-wheels/ -*.egg-info/ -.installed.cfg -*.egg -MANIFEST - -# PyInstaller -# Usually these files are written by a python script from a template -# before PyInstaller builds the exe, so as to inject date/other infos into it. -*.manifest -*.spec - -# Installer logs -pip-log.txt -pip-delete-this-directory.txt # Unit test / coverage reports htmlcov/ -.tox/ -.nox/ .coverage .coverage.* -.cache -nosetests.xml -coverage.xml -*.cover -*.py,cover -.hypothesis/ .pytest_cache/ -cover/ +coverage.xml coverage.json -# Translations -*.mo -*.pot - -# Django stuff: -*.log -local_settings.py -db.sqlite3 -db.sqlite3-journal - -# Flask stuff: -instance/ -.webassets-cache - -# Scrapy stuff: -.scrapy - -# Sphinx documentation -docs/_build/ - -# PyBuilder -.pybuilder/ -target/ - -# Jupyter Notebook -.ipynb_checkpoints - -# IPython -profile_default/ -ipython_config.py - -# pyenv -# For a library or package, you might want to ignore these files since the code is -# intended to run in multiple environments; otherwise, check them in: -# .python-version - -# pipenv -# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. -# However, in case of collaboration, if having platform-specific dependencies or dependencies -# having no cross-platform support, pipenv may install dependencies that don't work, or not -# install all needed dependencies. -#Pipfile.lock - -# poetry -# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. -# This is especially recommended for binary packages to ensure reproducibility, and is more -# commonly ignored for libraries. -# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control -#poetry.lock - -# pdm -# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. -#pdm.lock -# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it -# in version control. -# https://pdm.fming.dev/#use-with-ide -.pdm.toml - -# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm -__pypackages__/ - -# Celery stuff -celerybeat-schedule -celerybeat.pid - -# SageMath parsed files -*.sage.py # Environments .env .venv env/ venv/ -ENV/ -env.bak/ -venv.bak/ - -# Spyder project settings -.spyderproject -.spyproject - -# Rope project settings -.ropeproject - -# mkdocs documentation -/site # mypy .mypy_cache/ -.dmypy.json -dmypy.json - -# Pyre type checker -.pyre/ - -# pytype static type analyzer -.pytype/ - -# Cython debug symbols -cython_debug/ - -# PyCharm -# JetBrains specific template is maintained in a separate JetBrains.gitignore that can -# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore -# and can be added to the global gitignore or merged into this file. For a more nuclear -# option (not recommended) you can uncomment the following to ignore the entire idea folder. -#.idea/ +# Possible PDF generated from testing tests/outputs/** diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 6a4c9c1..60646ef 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -37,7 +37,7 @@ repos: exclude: "(^Pipfile\\.lock$)" # Python hooks - repo: https://github.com/astral-sh/ruff-pre-commit - rev: 'v0.1.5' + rev: 'v0.1.6' hooks: - id: ruff - repo: https://github.com/psf/black diff --git a/pyproject.toml b/pyproject.toml index db81536..1c88a51 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -84,10 +84,9 @@ cov = [ "cov-html" ] -[[tool.hatch.envs.all.matrix]] -python = ["3.8", "3.9", "3.10", "3.11", "3.12"] - [tool.hatch.envs.pre-commit] +template = "pre-commit" +detached = true dependencies = [ "pre-commit>=3.5.0", ] diff --git a/tests/test_health.py b/tests/test_health.py index 84f415e..ff58223 100644 --- a/tests/test_health.py +++ b/tests/test_health.py @@ -11,5 +11,6 @@ def test_health_endpoint( assert status.overall == StatusOptions.Up assert status.chromium is not None assert status.chromium.status == StatusOptions.Up - assert status.uno is not None - assert status.uno.status == StatusOptions.Up + if "uno" in status.data: + assert status.uno is not None + assert status.uno.status == StatusOptions.Up From 0269f40edf185a6615c808c3c93e0c2cf9c2c33e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 1 Dec 2023 11:45:45 +0000 Subject: [PATCH 6/9] Bump pypa/gh-action-pypi-publish from 1.8.10 to 1.8.11 Bumps [pypa/gh-action-pypi-publish](https://github.com/pypa/gh-action-pypi-publish) from 1.8.10 to 1.8.11. - [Release notes](https://github.com/pypa/gh-action-pypi-publish/releases) - [Commits](https://github.com/pypa/gh-action-pypi-publish/compare/v1.8.10...v1.8.11) --- updated-dependencies: - dependency-name: pypa/gh-action-pypi-publish dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 241463a..4942634 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -223,4 +223,4 @@ jobs: path: dist - name: Publish build to PyPI - uses: pypa/gh-action-pypi-publish@v1.8.10 + uses: pypa/gh-action-pypi-publish@v1.8.11 From 5da99c4121b9757e924b03a72cc62b512f1d8880 Mon Sep 17 00:00:00 2001 From: Trenton Holmes <797416+stumpylog@users.noreply.github.com> Date: Mon, 4 Dec 2023 07:47:05 -0800 Subject: [PATCH 7/9] Updates the image version used for testing and reduces the logging level --- .docker/docker-compose.ci-test-edge.yml | 4 ++++ .docker/docker-compose.ci-test.yml | 6 +++++- CHANGELOG.md | 2 ++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/.docker/docker-compose.ci-test-edge.yml b/.docker/docker-compose.ci-test-edge.yml index df165b5..810c15e 100644 --- a/.docker/docker-compose.ci-test-edge.yml +++ b/.docker/docker-compose.ci-test-edge.yml @@ -10,3 +10,7 @@ services: container_name: gotenberg-client-test-server network_mode: host restart: unless-stopped + command: + - "gotenberg" + - "--log-level=warn" + - "--log-format=text" diff --git a/.docker/docker-compose.ci-test.yml b/.docker/docker-compose.ci-test.yml index c01b639..8926026 100644 --- a/.docker/docker-compose.ci-test.yml +++ b/.docker/docker-compose.ci-test.yml @@ -5,8 +5,12 @@ version: "3" services: gotenberg-client-test-server: - image: docker.io/gotenberg/gotenberg:7.9.2 + image: docker.io/gotenberg/gotenberg:7.10.1 hostname: gotenberg-client-test-server container_name: gotenberg-client-test-server network_mode: host restart: unless-stopped + command: + - "gotenberg" + - "--log-level=warn" + - "--log-format=text" diff --git a/CHANGELOG.md b/CHANGELOG.md index 725a4d4..7e2ff69 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Removed some certain special cases from coverage - Updated `pre-commit` hook versions - Updated how pytest is configured, so it will apply to any invocation +- Updated test running image to log at warning or lower using text format +- Updated test running image from 7.9.2 to 7.10.1 ### Added From 52426e99b9ce677ba5614c54eb952b57bce81885 Mon Sep 17 00:00:00 2001 From: Trenton Holmes <797416+stumpylog@users.noreply.github.com> Date: Mon, 4 Dec 2023 07:00:39 -0800 Subject: [PATCH 8/9] Test out sending all the options for PDF/A format, see if it works on edge --- CHANGELOG.md | 2 ++ src/gotenberg_client/_base.py | 6 +++++- src/gotenberg_client/_client.py | 2 +- src/gotenberg_client/_convert/chromium.py | 2 +- src/gotenberg_client/_convert/common.py | 2 +- src/gotenberg_client/_convert/libre_office.py | 2 +- src/gotenberg_client/_convert/pdfa.py | 2 +- .../{_types_compat.py => _typing_compat.py} | 0 src/gotenberg_client/options.py | 9 ++++++--- 9 files changed, 18 insertions(+), 9 deletions(-) rename src/gotenberg_client/{_types_compat.py => _typing_compat.py} (100%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7e2ff69..714ffcc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Updated how pytest is configured, so it will apply to any invocation - Updated test running image to log at warning or lower using text format - Updated test running image from 7.9.2 to 7.10.1 +- For the moment, send both `pdfa` and `pdfFormat` for compatibility with 7.9 and 7.10 + - See [here](https://github.com/stumpylog/gotenberg-client/issues/5#issuecomment-1839081129) for some subtle differences in what these options mean ### Added diff --git a/src/gotenberg_client/_base.py b/src/gotenberg_client/_base.py index 42aa930..bf223bf 100644 --- a/src/gotenberg_client/_base.py +++ b/src/gotenberg_client/_base.py @@ -13,7 +13,7 @@ from httpx import Response from httpx._types import RequestFiles -from gotenberg_client._types_compat import Self +from gotenberg_client._typing_compat import Self from gotenberg_client._utils import guess_mime_type from gotenberg_client.options import PdfAFormat @@ -114,6 +114,10 @@ def pdf_format(self, pdf_format: PdfAFormat) -> Self: self._form_data.update(pdf_format.to_form()) return self + def universal_access_pdf(self, *, pdf_ua: bool) -> Self: + self._form_data.update({"pdfua": str(pdf_ua).lower()}) + return self + def trace(self, trace_id: str) -> Self: self._headers["Gotenberg-Trace"] = trace_id return self diff --git a/src/gotenberg_client/_client.py b/src/gotenberg_client/_client.py index 9068dad..9677d20 100644 --- a/src/gotenberg_client/_client.py +++ b/src/gotenberg_client/_client.py @@ -14,7 +14,7 @@ from gotenberg_client._convert.pdfa import PdfAApi from gotenberg_client._health import HealthCheckApi from gotenberg_client._merge import MergeApi -from gotenberg_client._types_compat import Self +from gotenberg_client._typing_compat import Self class GotenbergClient: diff --git a/src/gotenberg_client/_convert/chromium.py b/src/gotenberg_client/_convert/chromium.py index dfbc461..88850f0 100644 --- a/src/gotenberg_client/_convert/chromium.py +++ b/src/gotenberg_client/_convert/chromium.py @@ -11,7 +11,7 @@ from gotenberg_client._base import BaseApi from gotenberg_client._convert.common import ConvertBaseRoute -from gotenberg_client._types_compat import Self +from gotenberg_client._typing_compat import Self from gotenberg_client.options import EmulatedMediaType from gotenberg_client.options import Margin from gotenberg_client.options import PageSize diff --git a/src/gotenberg_client/_convert/common.py b/src/gotenberg_client/_convert/common.py index afb88fb..dac2fba 100644 --- a/src/gotenberg_client/_convert/common.py +++ b/src/gotenberg_client/_convert/common.py @@ -4,7 +4,7 @@ import logging from gotenberg_client._base import BaseRoute -from gotenberg_client._types_compat import Self +from gotenberg_client._typing_compat import Self from gotenberg_client.options import PageOrientation logger = logging.getLogger() diff --git a/src/gotenberg_client/_convert/libre_office.py b/src/gotenberg_client/_convert/libre_office.py index 65654f8..29c508c 100644 --- a/src/gotenberg_client/_convert/libre_office.py +++ b/src/gotenberg_client/_convert/libre_office.py @@ -6,7 +6,7 @@ from gotenberg_client._base import BaseApi from gotenberg_client._convert.common import ConvertBaseRoute -from gotenberg_client._types_compat import Self +from gotenberg_client._typing_compat import Self class LibreOfficeConvertRoute(ConvertBaseRoute): diff --git a/src/gotenberg_client/_convert/pdfa.py b/src/gotenberg_client/_convert/pdfa.py index d0ba3e2..cb95156 100644 --- a/src/gotenberg_client/_convert/pdfa.py +++ b/src/gotenberg_client/_convert/pdfa.py @@ -6,7 +6,7 @@ from gotenberg_client._base import BaseApi from gotenberg_client._convert.common import ConvertBaseRoute -from gotenberg_client._types_compat import Self +from gotenberg_client._typing_compat import Self class PdfAConvertRoute(ConvertBaseRoute): diff --git a/src/gotenberg_client/_types_compat.py b/src/gotenberg_client/_typing_compat.py similarity index 100% rename from src/gotenberg_client/_types_compat.py rename to src/gotenberg_client/_typing_compat.py diff --git a/src/gotenberg_client/options.py b/src/gotenberg_client/options.py index 4751de7..d2ef4ae 100644 --- a/src/gotenberg_client/options.py +++ b/src/gotenberg_client/options.py @@ -18,12 +18,15 @@ class PdfAFormat(enum.Enum): A3b = enum.auto() def to_form(self) -> Dict[str, str]: + format_name = None if self.value == PdfAFormat.A1a.value: - return {"pdfFormat": "PDF/A-1a"} + format_name = "PDF/A-1a" elif self.value == PdfAFormat.A2b.value: - return {"pdfFormat": "PDF/A-2b"} + format_name = "PDF/A-2b" elif self.value == PdfAFormat.A3b.value: - return {"pdfFormat": "PDF/A-3b"} + format_name = "PDF/A-3b" + if format_name is not None: + return {"pdfa": format_name, "pdfFormat": format_name} else: # pragma: no cover raise NotImplementedError(self.value) From 6428ac715c8bd5db67fdc6a5b7a345064bf5768d Mon Sep 17 00:00:00 2001 From: Trenton Holmes <797416+stumpylog@users.noreply.github.com> Date: Mon, 4 Dec 2023 09:40:02 -0800 Subject: [PATCH 9/9] Bumps version to 0.4.0 --- CHANGELOG.md | 2 +- src/gotenberg_client/__about__.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 714ffcc..b4f1341 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [Unreleased] +## [0.4.0] - 2023-12-04 ### Changed diff --git a/src/gotenberg_client/__about__.py b/src/gotenberg_client/__about__.py index 1812219..ece3781 100644 --- a/src/gotenberg_client/__about__.py +++ b/src/gotenberg_client/__about__.py @@ -1,4 +1,4 @@ # SPDX-FileCopyrightText: 2023-present Trenton H # # SPDX-License-Identifier: MPL-2.0 -__version__ = "0.3.0" +__version__ = "0.4.0"