Docmaker
Docmaker is a framework to create forms to generate docx documents. It uses docxtpl and pyside6 libs.
Install
You need to have python 3.11 installed and install dockmaker with command below:
pip install docmaker
Creating models
In order to create a model you have to create a new instance of DocModel defining the templates folder and the widget matrix as example below. You have to point the folder where your templates docx are.
# app.py
from docmaker.gui import widgets as wt
from docmaker.gui.widgets.types import ValidationError
from docmaker.converters import StringListConverter, DateConverter
from docmaker import DocModel
from docmaker import App
from pathlib import Path
import os
SCRIPT_DIR = Path(os.path.dirname(os.path.realpath(__file__)))
def convert_pericia(value: str) -> dict:
ret = {}
try:
parts = value.split("/")
ret['seq'], ret['rg'], ret['ano'] = int(
parts[0]), int(parts[1]), int(parts[2])
return ret
except:
raise ValidationError("Valor incorreto")
celular_model = DocModel(
"Celular",
templates_folder=SCRIPT_DIR / "models/celular/templates",
lists_folder=SCRIPT_DIR / "models/celular/listas",
)
celular_model.widgets = [
[
wt.SText("pericia", label="Pericia", placeholder="SEQ/RG/ANO", converter=convert_pericia),
wt.SText("requisitante", label="Requisitante"),
wt.SText("procedimento", label="Procedimento", placeholder="RAI ou inquérito"),
wt.SText("ocorrencia_odin", label="Ocorrência ODIN"),
wt.SSpinBox("n_objetos", label="N de objetos", required=True, default=1)
],
[
wt.SText("data_odin", label="Data ODIN", converter=DateConverter()),
wt.SText("inicio_exame", label="Inicio Exame", converter=DateConverter()),
wt.SText("data_recimento", label="data de recebimento", converter=DateConverter()),
],
[
wt.SText("n_quesito", label="Número quesito"),
wt.SText("autoridade", label="Autoridade"),
],
[
wt.SText("relatores", label="Relatores", placeholder="Relatores separados por vírgula",
required=True, converter=StringListConverter()),
wt.SText("revisores", label="Revisores", placeholder="Revisores separados por vírgula", converter=StringListConverter()),
],
[
wt.SText("lacre_entrada", label="Lacre entrada"),
wt.SText("lacre_saida", label="Lacre saída"),
wt.SComboBox("n_midias", "Nº Mídias", choices="opcoes_midias")
]
]
@celular_model.pre_process()
def pre_process(context):
context['peritos'] = context['relatores'] + context['revisores']
return context
app = App()
app.add_docmodel(celular_model)
app.run_gui()
Run application
python app.py
Metadata
Release files for docmaker 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| docmaker-0.1.1.tar.gz | 481.5 kB | Without provenance | Details for docmaker-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| docmaker-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for docmaker-0.1.1-py3-none-any.whl |
Total release size: 992.2 kB
Release files / docmaker-0.1.1.tar.gz
| Download URL | docmaker-0.1.1.tar.gz |
|---|---|
| Size | 481.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e7aaf92e16ac7bf6cf631d1461aa1c94b4eccd29d173625372f8e366e8c03fed
|
|
BLAKE2b-256 checksum How to use checksums |
535e62cd57ec58aaf280867ed1b18b3302e64d52fb0491efdcc5cd531fd3b559
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.7.1 CPython/3.11.5 Linux/6.6.1-arch1-1
|
Release files / docmaker-0.1.1-py3-none-any.whl
| Download URL | docmaker-0.1.1-py3-none-any.whl |
|---|---|
| Size | 510.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d1814c817ccd233825fcca6de37d04a3ea7f2771f978ea57e9df9518862153f4
|
|
BLAKE2b-256 checksum How to use checksums |
d45ba402c1e2c22c83a40db1d457e7c0736d90c69785fb6f27a8d9e7a2f71644
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.7.1 CPython/3.11.5 Linux/6.6.1-arch1-1
|
Security for docmaker 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.
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.