Skip to main content

simple report automatic rendering

Project description

okreport: simple report automatic rendering

Installation

pip install python-okreport

Usage

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):
    """
    In result, x = {{ x }}, y = {{ y }}, sum is {{ sum }}.
    """
    x = ResultX()
    y = ResultY()
    sum = ResultSum()


class ConfParagraph(Paragraph):
    """
    In conf, x = {{ x }}, y = {{ y }}, sum is {{ sum }}.
    """
    x = ConfX()
    y = ConfY()
    sum = ConfSum()


class MyReport(Report):
    """
    {{ p1 }}
    {{ p2 }}
    """
    p1 = ResultParagraph()
    p2 = ConfParagraph()


result = {'x': 1, 'y': 2}
conf = {'x': 3, 'y': 4}
my_report = MyReport()
text = my_report.render(result, conf, None)
print(text)

Project details


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.0.0.tar.gz (2.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

python_okreport-1.0.0-py2.py3-none-any.whl (2.6 kB view details)

Uploaded Python 2Python 3

File details

Details for the file python-okreport-1.0.0.tar.gz.

File metadata

  • Download URL: python-okreport-1.0.0.tar.gz
  • Upload date:
  • Size: 2.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.9.6

File hashes

Hashes for python-okreport-1.0.0.tar.gz
Algorithm Hash digest
SHA256 949387bedb2d75d1635933a3cf38e052918ef833fbfb91d9d7ea8df61430af7e
MD5 f15ee62f9032fa3f0be9e3648cc024d9
BLAKE2b-256 79d6aa29df890716abc7c3f642aef4632e8b6b05211e4d2a37e9ba1873ba4d44

See more details on using hashes here.

File details

Details for the file python_okreport-1.0.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for python_okreport-1.0.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 9c20a39e4b4949ff36f5c6307eada75c51efb71480fd6ca4c1a5d9502ae9c585
MD5 3be2d091af93b4fcb4a1331cb69550fd
BLAKE2b-256 dc0c27fae5940a437dcd8ea2873335bffa0a4dbd7b79fe89c899732b3ecf899c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page