Report Generation Utils
Collection of Python tools for generating reports in various formats.
Usage
from report-generation-utils import ReportGeneratorManager
config_file = "conf/config.yaml"
config = yaml.safe_load(Path(config_file).read_text())
# Path to your Jinja2 template file
template_file = "templates/report_template_v1.txt"
# Alternatively, can provide an HTML template.
# See templates/report_template_v1.html and templates/report_template_v2.html
manager = Manager(
config=config,
config_file=config_file,
executable=os.path.abspath(__file__),
logfile=logfile,
outdir=outdir,
outfile=outfile,
template_file=template_file,
verbose=verbose
)
manager.register_data_file(
constants.DEFAULT_CONFIG_FILE,
"The configuration file",
"The YAML configuration file for this project."
)
manager.register_data_file(
os.path.join(
os.path.dirname(__file__),
"constants.py"
),
"The constants file",
"The Python constants file for this project."
)
manager.add_runtime_parameter(
"--logfile",
os.path.abspath(logfile),
"The log file",
"The Python logging log file."
)
manager.add_runtime_parameter(
"--template_file",
os.path.abspath(template_file),
"The template file",
"The Python Jinja2 template file use to generate this report."
)
lookup = [
{
"key": "A",
"val": "The first letter of the alphabet"
},
{
"key": "B",
"val": "The second letter of the alphabet"
},
{
"key": "C",
"val": "The third letter of the alphabet"
}
]
manager.generate_report(lookup)
Contents of the report file:
##------------------------------------------------------------
## Summary
##------------------------------------------------------------
Report Title:
Description: This is the batch analysis report.
Report date: 2025-02-15-110523
For research use only.
Contact lab for patient sample identifier maps.
For all questions, contact the Chief Medical Officer.
##------------------------------------------------------------
## Report Section
##------------------------------------------------------------
A: The first letter of the alphabet
B: The second letter of the alphabet
C: The third letter of the alphabet
##------------------------------------------------------------
## Runtime Parameters Section
##------------------------------------------------------------
Name: The log file
Key: --logfile
Value: /tmp/demo-report-generation-utils/generate_report.log
Description: The Python logging log file.
Name: The template file
Key: --template_file
Value: /tmp/demo-report-generation-utils/report_template_v1.txt
Description: The Python Jinja2 template file use to generate this report.
##------------------------------------------------------------
## Data Files Section
##------------------------------------------------------------
Name: The configuration file
File: /tmp/report-generation-utils/venv/lib/python3.10/site-packages/report_generation_utils/conf/config.yaml
Checksum: 1accb09b91be9ba593fcee7c28620ba0
Description: The YAML configuration file for this project.
Name: The constants file
File: /tmp/report-generation-utils/venv/lib/python3.10/site-packages/report_generation_utils/constants.py
Checksum: d8aeae3f93d45393681a0f956573a152
Description: The Python constants file for this project.
##------------------------------------------------------------
## Miscellaneous
##------------------------------------------------------------
Method Created: /tmp/report-generation-utils/venv/lib/python3.10/site-packages/report_generation_utils/generate_report.py
Date Created: 2025-02-15-110523
Created By: sundaram
Logfile: /tmp/demo-report-generation-utils/generate_report.log
Template File: /tmp/demo-report-generation-utils/report_template_v1.txt
History
0.1.0 (2024-03-14)
First release on PyPI.
Metadata
Release files for report-generation-utils 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| report_generation_utils-0.1.2.tar.gz | 18.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| report_generation_utils-0.1.2-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details |
Total release size: 33.3 kB
Release files / report_generation_utils-0.1.2.tar.gz
| Download URL | report_generation_utils-0.1.2.tar.gz |
|---|---|
| Size | 18.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
06700a629243d8f1295c88f78b7abbca3a0a42a9f64d6a52d18e90176f92200e
|
|
BLAKE2b-256 checksum How to use checksums |
16c2f1940c5d8dab617c475c2630b9186ac7845f23e357e7b938b45589d7b825
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.10.12
|
Release files / report_generation_utils-0.1.2-py2.py3-none-any.whl
| Download URL | report_generation_utils-0.1.2-py2.py3-none-any.whl |
|---|---|
| Size | 15.0 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
fff2521471ecfcaa12ce5b9fb05ea91f6551a84bf37af89f25e63d87a7cad152
|
|
BLAKE2b-256 checksum How to use checksums |
490747bc5e836cb631083ad177912eafb967a49635ad30dca56444358ae8a960
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.10.12
|