Skip to main content

isis-report-lib

Biblioteca Python para geração de relatórios PDF tabulares com layouts hierárquicos customizáveis — extraída do POC isis_report (microserviço Robyn), sem o servidor.

  • Entrada: dict/ReportPayload (meta + layout opcional + data) ou texto .toon
  • Renderização: Jinja2 (templates embutidos no pacote)
  • PDF: Playwright (Chromium)
  • API: síncrona (generate_pdf) + assíncrona (agenerate_pdf)

Instalação

pip install isis-report-lib
playwright install chromium   # necessário p/ gerar PDF

Dev:

pip install -e ".[dev]"

Uso rápido

from isis_report_lib import generate_pdf, generate_pdf_from_toon, render_html

payload = {
    "meta": {"title": "Pedido de Vendas", "sub_title": "2024", "mode": "exact"},
    "layout": {
        "empresa": {"label": "Empresa", "format_mask": "str", "alignment": "left"},
        "pedidos": {
            "pedido": {"label": "Código", "format_mask": "int", "alignment": "right"},
            "valor_total": {"label": "Valor Total", "format_mask": "float", "alignment": "right"},
        },
    },
    "data": [{"empresa": "CQ CONSULTORIA", "pedidos": [{"pedido": 750, "valor_total": 4000}]}],
}

pdf_bytes = generate_pdf(payload)
open("relatorio.pdf", "wb").write(pdf_bytes)

# Sem Playwright: só o HTML intermediário
html = render_html(payload)

# A partir de .toon
toon = open("examples/pedido.toon", encoding="utf-8").read()
open("relatorio_toon.pdf", "wb").write(generate_pdf_from_toon(toon))

Async:

from isis_report_lib import agenerate_pdf, agenerate_pdf_from_toon

pdf = await agenerate_pdf(payload)
pdf = await agenerate_pdf_from_toon(toon_text)

Opções do PDF (repassadas ao page.pdf do Playwright):

generate_pdf(payload, pdf_options={"format": "A4", "margin": {"top": ".2in", "bottom": ".5in"}})

Exemplo completo em examples/.

Payload

Campo Tipo Obrigatório Descrição
meta object sim title, sub_title, mode ("exact"/"gray"), company
layout object não definição hierárquica; omitir = inferido dos dados
data array sim registros crus ou formato template ({"fields": ..., "groups": ...})

Máscaras: str · int (milhar 1.234) · float (pt-BR 1.234,50) · date.

Sintaxe .toon

meta:
  title: Pedido de Vendas
  mode: exact
layout:
  produto{Produto,str,left}
  valor{Valor,float,right}
dados[1]:
  - produto: Caneta
    valor: 5.50

dados[n] é mapeado para data. Ver examples/pedido.toon.

API

Função Descrição
generate_pdf(payload, pdf_options?) -> bytes PDF sync a partir de dict/ReportPayload
agenerate_pdf(...) idem, async
generate_pdf_from_toon(text, ...) / agenerate_pdf_from_toon PDF a partir de .toon
render_html(payload) / arender_html / render_html_from_toon HTML intermediário (sem browser)
ToonParser().parse(text) / parse_toon(text) parse .toon -> dict
TabularReportService(pdf_options?) pipeline execute(payload) (Obter→Tratar→HTML→PDF)

Testes

pytest -q
ruff check src tests

Testes de PDF real exigem playwright install chromium e são pulados (-m "not browser") se o browser não estiver disponível.

Licença

MIT — ver LICENSE.

Metadata

Release files for isis-report-lib 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for isis-report-lib 0.1.1
File Size Uploaded Provenance Actions
isis_report_lib-0.1.1.tar.gz 20.0 kB With provenance Details for isis_report_lib-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for isis-report-lib 0.1.1
File Interpreter ABI Platform Actions
isis_report_lib-0.1.1-py3-none-any.whl Python 3 none any Details for isis_report_lib-0.1.1-py3-none-any.whl

Total release size: 37.6 kB

Release files / isis_report_lib-0.1.1.tar.gz

Download URL isis_report_lib-0.1.1.tar.gz
Size 20.0 kB
Tags Source
SHA-256 checksum
How to use checksums
d569ae987feb33f846db1e7b74966d984111e24e773b77a53a0ee460e2adb079
BLAKE2b-256 checksum
How to use checksums
a4690f0c8cd690d49ef8b748203c25858092483c575513a753e5776e5c33b746
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 9, 2026.

Transparency log

Release files / isis_report_lib-0.1.1-py3-none-any.whl

Download URL isis_report_lib-0.1.1-py3-none-any.whl
Size 17.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bc5be78670a5ca08dc6ac705ef102e40785eb92c37813151dab8ee83aa59964e
BLAKE2b-256 checksum
How to use checksums
e96f8b561d1f9a693cc8ea46d7d82186c8902eadbe98e54686b3aae43e450efc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 9, 2026.

Transparency log

Security for isis-report-lib 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for isis_report_lib-0.1.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 9, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page