simple report automatic rendering
Project description
okreport: simple report automatic rendering
Installation
pip install python-okreport
Usage
from jinja2 import Template
from okreport import Var, Paragraph, Report
class ResultX(Var):
def parse(self, result, conf, env): # noqa
return result['x']
class ResultY(Var):
def parse(self, result, conf, env): # noqa
return result['y']
class ResultSum(Var):
def parse(self, result, conf, env): # noqa
return result['x'] + result['y']
class ConfX(Var):
def parse(self, result, conf, env): # noqa
return conf['x']
class ConfY(Var):
def parse(self, result, conf, env): # noqa
return conf['y']
class ConfSum(Var):
def parse(self, result, conf, env): # noqa
return conf['x'] + conf['y']
class ResultParagraph(Paragraph):
x = ResultX()
y = ResultY()
sum = ResultSum()
class ConfParagraph(Paragraph):
x = ConfX()
y = ConfY()
sum = ConfSum()
class MyReport(Report):
"""
In result, x = {{ p1.x }}, y = {{ p1.y }}, sum = {{ p1.sum }}.
In conf, x = {{ p2.x }}, y = {{ p2.y }}, sum = {{ p2.sum }}.
"""
p1 = ResultParagraph()
p2 = ConfParagraph()
def get_template(self):
return Template(self.__doc__)
result = {'x': 1, 'y': 2}
conf = {'x': 3, 'y': 4}
my_report = MyReport()
text = my_report.render(result, conf, None)
print(text)
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
python-okreport-1.1.0.tar.gz
(3.2 kB
view details)
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 python-okreport-1.1.0.tar.gz.
File metadata
- Download URL: python-okreport-1.1.0.tar.gz
- Upload date:
- Size: 3.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.10.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c705e5f00afb075f48dd90f089f35adbc464c1e8dede27469be16db0b733e891
|
|
| MD5 |
31bee265cea9348c0f8e0abc300e0437
|
|
| BLAKE2b-256 |
a2f5a2cd729a5e7361706fe57561b3ad337f871cd02ef7beed4871d25f042aa0
|
File details
Details for the file python_okreport-1.1.0-py2.py3-none-any.whl.
File metadata
- Download URL: python_okreport-1.1.0-py2.py3-none-any.whl
- Upload date:
- Size: 2.6 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.10.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a73f6c81a228b13847ed105d3e713e7fdcc25f5cf9bb9ff425a93d42775e52d0
|
|
| MD5 |
fda6d3ddff3dc44b3b148bc96ab0c316
|
|
| BLAKE2b-256 |
abc2e1222da3f853b6f619070d78693f1f876946a324d449ec8cf333cdc9eceb
|