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.0

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.0
File Size Uploaded Provenance Actions
isis_report_lib-0.1.0.tar.gz 19.5 kB Without provenance Details for isis_report_lib-0.1.0.tar.gz

Built distribution (wheel)

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

Total release size: 37.0 kB

Release files / isis_report_lib-0.1.0.tar.gz

Download URL isis_report_lib-0.1.0.tar.gz
Size 19.5 kB
Tags Source
SHA-256 checksum
How to use checksums
0a1fb75b4eca5c6c88de6653688de4a05503ecfac4f1bb28bbddd84e065fe76d
BLAKE2b-256 checksum
How to use checksums
685272f5abf055c28682b943112a03892dd51706ef2b8de3221a84c8d63dc107
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.10

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

Download URL isis_report_lib-0.1.0-py3-none-any.whl
Size 17.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f5c0bfa45b5b35f125295cf366711828b763d2f6753a97fbf8e24c54fb110a99
BLAKE2b-256 checksum
How to use checksums
c7cc4d5651e880a4f5f63eccca56a1f0721016de6e9ec616e8e51d67cd71c585
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.10

Security for isis-report-lib 0.1.0

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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