Merge branch 'main' of git.nice.net.nz:hads/hinpdof
Some checks failed
Build and Publish Docker Image / build (push) Failing after 35s
Some checks failed
Build and Publish Docker Image / build (push) Failing after 35s
This commit is contained in:
78
poetry.lock
generated
78
poetry.lock
generated
@@ -630,13 +630,13 @@ tests = ["asttokens (>=2.1.0)", "coverage", "coverage-enable-subprocess", "ipyth
|
||||
|
||||
[[package]]
|
||||
name = "fastapi"
|
||||
version = "0.115.4"
|
||||
version = "0.115.6"
|
||||
description = "FastAPI framework, high performance, easy to learn, fast to code, ready for production"
|
||||
optional = false
|
||||
python-versions = ">=3.8"
|
||||
files = [
|
||||
{file = "fastapi-0.115.4-py3-none-any.whl", hash = "sha256:0b504a063ffb3cf96a5e27dc1bc32c80ca743a2528574f9cdc77daa2d31b4742"},
|
||||
{file = "fastapi-0.115.4.tar.gz", hash = "sha256:db653475586b091cb8b2fec2ac54a680ac6a158e07406e1abae31679e8826349"},
|
||||
{file = "fastapi-0.115.6-py3-none-any.whl", hash = "sha256:e9240b29e36fa8f4bb7290316988e90c381e5092e0cbe84e7818cc3713bcf305"},
|
||||
{file = "fastapi-0.115.6.tar.gz", hash = "sha256:9ec46f7addc14ea472958a96aae5b5de65f39721a46aaf5705c480d9a8b76654"},
|
||||
]
|
||||
|
||||
[package.dependencies]
|
||||
@@ -870,13 +870,13 @@ test = ["Cython (>=0.29.24)"]
|
||||
|
||||
[[package]]
|
||||
name = "httpx"
|
||||
version = "0.27.2"
|
||||
version = "0.28.0"
|
||||
description = "The next generation HTTP client."
|
||||
optional = false
|
||||
python-versions = ">=3.8"
|
||||
files = [
|
||||
{file = "httpx-0.27.2-py3-none-any.whl", hash = "sha256:7bb2708e112d8fdd7829cd4243970f0c223274051cb35ee80c03301ee29a3df0"},
|
||||
{file = "httpx-0.27.2.tar.gz", hash = "sha256:f7c2be1d2f3c3c3160d441802406b206c2b76f5947b11115e6df10c6c65e66c2"},
|
||||
{file = "httpx-0.28.0-py3-none-any.whl", hash = "sha256:dc0b419a0cfeb6e8b34e85167c0da2671206f5095f1baa9663d23bcfd6b535fc"},
|
||||
{file = "httpx-0.28.0.tar.gz", hash = "sha256:0858d3bab51ba7e386637f22a61d8ccddaeec5f3fe4209da3a6168dbb91573e0"},
|
||||
]
|
||||
|
||||
[package.dependencies]
|
||||
@@ -884,7 +884,6 @@ anyio = "*"
|
||||
certifi = "*"
|
||||
httpcore = "==1.*"
|
||||
idna = "*"
|
||||
sniffio = "*"
|
||||
|
||||
[package.extras]
|
||||
brotli = ["brotli", "brotlicffi"]
|
||||
@@ -974,13 +973,13 @@ i18n = ["Babel (>=2.7)"]
|
||||
|
||||
[[package]]
|
||||
name = "logfire"
|
||||
version = "2.1.2"
|
||||
version = "2.7.0"
|
||||
description = "The best Python observability tool! 🪵🔥"
|
||||
optional = false
|
||||
python-versions = ">=3.8"
|
||||
files = [
|
||||
{file = "logfire-2.1.2-py3-none-any.whl", hash = "sha256:894ea34ec1d2c87d69b61607dd66d894e93b08003e626a82b2ad167912eb038b"},
|
||||
{file = "logfire-2.1.2.tar.gz", hash = "sha256:b6a3caec6be514656eb664dff49b7b564faaf715f42f9bfc570fa68da8cba970"},
|
||||
{file = "logfire-2.7.0-py3-none-any.whl", hash = "sha256:21a5d4554997dd1242109b35a8e9dea91438b8958884a39e18c53c39ce980c9a"},
|
||||
{file = "logfire-2.7.0.tar.gz", hash = "sha256:d59677c9b17e927d9e8834442bc27d46a72f336afcb9a8e4116b9c3829b95b1b"},
|
||||
]
|
||||
|
||||
[package.dependencies]
|
||||
@@ -997,6 +996,7 @@ typing-extensions = ">=4.1.0"
|
||||
aiohttp = ["opentelemetry-instrumentation-aiohttp-client (>=0.42b0)"]
|
||||
asgi = ["opentelemetry-instrumentation-asgi (>=0.42b0)"]
|
||||
asyncpg = ["opentelemetry-instrumentation-asyncpg (>=0.42b0)"]
|
||||
aws-lambda = ["opentelemetry-instrumentation-aws-lambda (>=0.42b0)"]
|
||||
celery = ["opentelemetry-instrumentation-celery (>=0.42b0)"]
|
||||
django = ["opentelemetry-instrumentation-django (>=0.42b0)"]
|
||||
fastapi = ["opentelemetry-instrumentation-fastapi (>=0.42b0)"]
|
||||
@@ -1009,6 +1009,7 @@ pymongo = ["opentelemetry-instrumentation-pymongo (>=0.42b0)"]
|
||||
redis = ["opentelemetry-instrumentation-redis (>=0.42b0)"]
|
||||
requests = ["opentelemetry-instrumentation-requests (>=0.42b0)"]
|
||||
sqlalchemy = ["opentelemetry-instrumentation-sqlalchemy (>=0.42b0)"]
|
||||
sqlite3 = ["opentelemetry-instrumentation-sqlite3 (>=0.42b0)"]
|
||||
starlette = ["opentelemetry-instrumentation-starlette (>=0.42b0)"]
|
||||
system-metrics = ["opentelemetry-instrumentation-system-metrics (>=0.42b0)"]
|
||||
wsgi = ["opentelemetry-instrumentation-wsgi (>=0.42b0)"]
|
||||
@@ -1651,13 +1652,13 @@ test = ["pytest", "ruff"]
|
||||
|
||||
[[package]]
|
||||
name = "pytest"
|
||||
version = "8.3.3"
|
||||
version = "8.3.4"
|
||||
description = "pytest: simple powerful testing with Python"
|
||||
optional = false
|
||||
python-versions = ">=3.8"
|
||||
files = [
|
||||
{file = "pytest-8.3.3-py3-none-any.whl", hash = "sha256:a6853c7375b2663155079443d2e45de913a911a11d669df02a50814944db57b2"},
|
||||
{file = "pytest-8.3.3.tar.gz", hash = "sha256:70b98107bd648308a7952b06e6ca9a50bc660be218d53c257cc1fc94fda10181"},
|
||||
{file = "pytest-8.3.4-py3-none-any.whl", hash = "sha256:50e16d954148559c9a74109af1eaf0c945ba2d8f30f0a3d3335edde19788b6f6"},
|
||||
{file = "pytest-8.3.4.tar.gz", hash = "sha256:965370d062bce11e73868e0335abac31b4d3de0e82f4007408d242b4f8610761"},
|
||||
]
|
||||
|
||||
[package.dependencies]
|
||||
@@ -1813,6 +1814,33 @@ pygments = ">=2.13.0,<3.0.0"
|
||||
[package.extras]
|
||||
jupyter = ["ipywidgets (>=7.5.1,<9)"]
|
||||
|
||||
[[package]]
|
||||
name = "ruff"
|
||||
version = "0.7.4"
|
||||
description = "An extremely fast Python linter and code formatter, written in Rust."
|
||||
optional = false
|
||||
python-versions = ">=3.7"
|
||||
files = [
|
||||
{file = "ruff-0.7.4-py3-none-linux_armv6l.whl", hash = "sha256:a4919925e7684a3f18e18243cd6bea7cfb8e968a6eaa8437971f681b7ec51478"},
|
||||
{file = "ruff-0.7.4-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:cfb365c135b830778dda8c04fb7d4280ed0b984e1aec27f574445231e20d6c63"},
|
||||
{file = "ruff-0.7.4-py3-none-macosx_11_0_arm64.whl", hash = "sha256:63a569b36bc66fbadec5beaa539dd81e0527cb258b94e29e0531ce41bacc1f20"},
|
||||
{file = "ruff-0.7.4-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:0d06218747d361d06fd2fdac734e7fa92df36df93035db3dc2ad7aa9852cb109"},
|
||||
{file = "ruff-0.7.4-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:e0cea28d0944f74ebc33e9f934238f15c758841f9f5edd180b5315c203293452"},
|
||||
{file = "ruff-0.7.4-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:80094ecd4793c68b2571b128f91754d60f692d64bc0d7272ec9197fdd09bf9ea"},
|
||||
{file = "ruff-0.7.4-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:997512325c6620d1c4c2b15db49ef59543ef9cd0f4aa8065ec2ae5103cedc7e7"},
|
||||
{file = "ruff-0.7.4-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:00b4cf3a6b5fad6d1a66e7574d78956bbd09abfd6c8a997798f01f5da3d46a05"},
|
||||
{file = "ruff-0.7.4-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:7dbdc7d8274e1422722933d1edddfdc65b4336abf0b16dfcb9dedd6e6a517d06"},
|
||||
{file = "ruff-0.7.4-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:0e92dfb5f00eaedb1501b2f906ccabfd67b2355bdf117fea9719fc99ac2145bc"},
|
||||
{file = "ruff-0.7.4-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:3bd726099f277d735dc38900b6a8d6cf070f80828877941983a57bca1cd92172"},
|
||||
{file = "ruff-0.7.4-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:2e32829c429dd081ee5ba39aef436603e5b22335c3d3fff013cd585806a6486a"},
|
||||
{file = "ruff-0.7.4-py3-none-musllinux_1_2_i686.whl", hash = "sha256:662a63b4971807623f6f90c1fb664613f67cc182dc4d991471c23c541fee62dd"},
|
||||
{file = "ruff-0.7.4-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:876f5e09eaae3eb76814c1d3b68879891d6fde4824c015d48e7a7da4cf066a3a"},
|
||||
{file = "ruff-0.7.4-py3-none-win32.whl", hash = "sha256:75c53f54904be42dd52a548728a5b572344b50d9b2873d13a3f8c5e3b91f5cac"},
|
||||
{file = "ruff-0.7.4-py3-none-win_amd64.whl", hash = "sha256:745775c7b39f914238ed1f1b0bebed0b9155a17cd8bc0b08d3c87e4703b990d6"},
|
||||
{file = "ruff-0.7.4-py3-none-win_arm64.whl", hash = "sha256:11bff065102c3ae9d3ea4dc9ecdfe5a5171349cdd0787c1fc64761212fc9cf1f"},
|
||||
{file = "ruff-0.7.4.tar.gz", hash = "sha256:cd12e35031f5af6b9b93715d8c4f40360070b2041f81273d0527683d5708fce2"},
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "shellingham"
|
||||
version = "1.5.4"
|
||||
@@ -2126,24 +2154,24 @@ anyio = ">=3.0.0"
|
||||
|
||||
[[package]]
|
||||
name = "weasyprint"
|
||||
version = "63.0"
|
||||
version = "63.1"
|
||||
description = "The Awesome Document Factory"
|
||||
optional = false
|
||||
python-versions = ">=3.9"
|
||||
files = [
|
||||
{file = "weasyprint-63.0-py3-none-any.whl", hash = "sha256:57d02dcfd06811a1299730c01dcc0e14eb81e990c8c51844a7fc0351fd71ed83"},
|
||||
{file = "weasyprint-63.0.tar.gz", hash = "sha256:ec24c64fdcc63e4168b2c24eb89b1ee8a711281a7d7fdb3eed3f54995489c9d1"},
|
||||
{file = "weasyprint-63.1-py3-none-any.whl", hash = "sha256:9d0319fe3ba553c9a77dc43a2d35b64a70c2b8809ad55a139a214803fde62bce"},
|
||||
{file = "weasyprint-63.1.tar.gz", hash = "sha256:cb424e63e8dd3f14195bfe5f203527646aa40a2f00ac819f9d39b8304cec0044"},
|
||||
]
|
||||
|
||||
[package.dependencies]
|
||||
cffi = ">=0.6,<2"
|
||||
cssselect2 = ">=0.1,<0.8"
|
||||
fonttools = {version = ">=4.0.0,<5", extras = ["woff"]}
|
||||
Pillow = ">=9.1.0,<11"
|
||||
pydyf = ">=0.11.0,<0.12"
|
||||
Pyphen = ">=0.9.1,<0.16"
|
||||
tinycss2 = ">=1.4.0,<2"
|
||||
tinyhtml5 = ">=2.0.0b1,<3"
|
||||
cffi = ">=0.6"
|
||||
cssselect2 = ">=0.1"
|
||||
fonttools = {version = ">=4.0.0", extras = ["woff"]}
|
||||
Pillow = ">=9.1.0"
|
||||
pydyf = ">=0.11.0"
|
||||
Pyphen = ">=0.9.1"
|
||||
tinycss2 = ">=1.4.0"
|
||||
tinyhtml5 = ">=2.0.0b1"
|
||||
|
||||
[package.extras]
|
||||
doc = ["sphinx", "sphinx_rtd_theme"]
|
||||
@@ -2422,4 +2450,4 @@ test = ["pytest"]
|
||||
[metadata]
|
||||
lock-version = "2.0"
|
||||
python-versions = "^3.12"
|
||||
content-hash = "607f15adf3b52bd6f9a1fb613ef0bbf94db4dd3fe501450d5c8cd8876a2191a8"
|
||||
content-hash = "66cbb12603e0d88dfa1bb766130cf82545db47bc4bd93a2f9320d8ed60a7f189"
|
||||
|
||||
@@ -15,8 +15,9 @@ logfire = {extras = ["fastapi"], version = "^2.1.2"}
|
||||
|
||||
[tool.poetry.group.dev.dependencies]
|
||||
pytest = "^8.3.3"
|
||||
httpx = "^0.27.2"
|
||||
httpx = "^0.28.0"
|
||||
pytest-cov = "^4.0.0"
|
||||
ruff = "^0.7.0"
|
||||
pre-commit = "^3.4.0"
|
||||
|
||||
[build-system]
|
||||
|
||||
6
renovate.json
Normal file
6
renovate.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
|
||||
"extends": [
|
||||
"local>hads/renovate-config"
|
||||
]
|
||||
}
|
||||
59
test.py
Executable file
59
test.py
Executable file
@@ -0,0 +1,59 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
"""
|
||||
Opens the `test.j2` HTML template and sends it to the hinpdof API service to convert
|
||||
it to a PDF file and saves the result to the `test.pdf` file.
|
||||
"""
|
||||
|
||||
import requests
|
||||
from jinja2 import Environment, FileSystemLoader
|
||||
|
||||
# hinpdof API service openapi url: https://hinpdof.huna.me/openapi.json
|
||||
|
||||
|
||||
def render_template(template_name, context):
|
||||
"""Render the Jinja2 template with the given context."""
|
||||
env = Environment(loader=FileSystemLoader("."))
|
||||
template = env.get_template(template_name)
|
||||
return template.render(context)
|
||||
|
||||
|
||||
def convert_html_to_pdf(html_content):
|
||||
"""Send the HTML content to the hinpdof API service to convert it to a PDF file."""
|
||||
api_url = "https://hinpdof.huna.me/pdf"
|
||||
api_url = "http://localhost:8000/pdf"
|
||||
headers = {
|
||||
"Content-Type": "application/json",
|
||||
"x-secret-key": "foo",
|
||||
}
|
||||
data = {
|
||||
"html": html_content,
|
||||
}
|
||||
response = requests.post(api_url, json=data, headers=headers)
|
||||
response.raise_for_status()
|
||||
return response.content
|
||||
|
||||
|
||||
def save_pdf(pdf_content, output_path):
|
||||
"""Save the PDF content to a file."""
|
||||
with open(output_path, "wb") as pdf_file:
|
||||
pdf_file.write(pdf_content)
|
||||
|
||||
|
||||
def main():
|
||||
# Render the Jinja2 template
|
||||
template_name = "test.j2"
|
||||
context = {} # Add any context variables needed for the template
|
||||
html_content = render_template(template_name, context)
|
||||
|
||||
# Convert the HTML content to a PDF file
|
||||
pdf_content = convert_html_to_pdf(html_content)
|
||||
|
||||
# Save the PDF file
|
||||
output_path = "test.pdf"
|
||||
save_pdf(pdf_content, output_path)
|
||||
print(f"PDF file saved to {output_path}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user