Collection of Python tools for generating reports in various formats.
Project description
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file report_generation_utils-0.1.2.tar.gz.
File metadata
- Download URL: report_generation_utils-0.1.2.tar.gz
- Upload date:
- Size: 18.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
06700a629243d8f1295c88f78b7abbca3a0a42a9f64d6a52d18e90176f92200e
|
|
| MD5 |
d1e28c5e618a5c08de4266473ed124ea
|
|
| BLAKE2b-256 |
16c2f1940c5d8dab617c475c2630b9186ac7845f23e357e7b938b45589d7b825
|
File details
Details for the file report_generation_utils-0.1.2-py2.py3-none-any.whl.
File metadata
- Download URL: report_generation_utils-0.1.2-py2.py3-none-any.whl
- Upload date:
- Size: 15.0 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fff2521471ecfcaa12ce5b9fb05ea91f6551a84bf37af89f25e63d87a7cad152
|
|
| MD5 |
c3ea17338f4054e16d3392cd2112ca18
|
|
| BLAKE2b-256 |
490747bc5e836cb631083ad177912eafb967a49635ad30dca56444358ae8a960
|