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()
    
    def get_template_text(self, result, conf, env):  # noqa
        return self.__doc__


class ConfParagraph(Paragraph):
    """
    In conf, x = {{ x }}, y = {{ y }}, sum is {{ sum }}.
    """
    x = ConfX()
    y = ConfY()
    sum = ConfSum()
    
    def get_template_text(self, result, conf, env):  # noqa
        return self.__doc__


class MyReport(Report):
    """
    {{ p1 }}
    {{ p2 }}
    """
    p1 = ResultParagraph()
    p2 = ConfParagraph()
    
    def get_template_text(self, result, conf, env):  # noqa
        return 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


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.1.tar.gz (3.3 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.1-py2.py3-none-any.whl (2.7 kB view details)

Uploaded Python 2Python 3

File details

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

File metadata

  • Download URL: python-okreport-1.0.1.tar.gz
  • Upload date:
  • Size: 3.3 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.1.tar.gz
Algorithm Hash digest
SHA256 761f36548981d5669009df299e1c80ba5511ad00371aa149ff888d9d86664bc3
MD5 68cf9365cfbeef81916578a764b5034e
BLAKE2b-256 9555355d2edb4cd896e6658a73ae4e9c6ad2b286889f89e8a0ee30d4cb9c43f2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_okreport-1.0.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 0137243282d3d28c9f3ebea619cfec8052b910feb172fe4110339846c21c98e8
MD5 d0164781d5dbd45034f4edbf459b3054
BLAKE2b-256 228b3fbf9afc1b116de84a4679f538563b18b2ea4907133773a93b05668c25ce

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