- class kpireport.report.Content(j2: Environment, report: Report)¶
The rendered report, in a variety of formats.
Jinja2context to use for loading and rendering templates.
the list of all formats available for the report. Any formats added via
add_format()will be reflected here.
- add_format(fmt: str, views: list[View])¶
Render the specified format and add to the output contents.
If a layout file is found for this format, it will be used to render the raw output. If a layout file is not found, there will be no raw output, however, the list of Views will still be stored for the output format. This can be important for output drivers that may not be able to display/send a final rendered report in text, but could still render each view separately. The Slack output driver is a good example of this.
The layout file is expected to exist at
./template/layout/default.htmlfor the HTML format.
fmt (str) – the output format, e.g.,
views (List[View]) – the list of Views to render
- get_format(fmt: str) Optional[str] ¶
Get the rendered string for the given format.
fmt (str) – the desired output format.
the rendered content for the given format, if any.
- Return type
- class kpireport.report.Report(title=None, interval_days=None, start_date=None, end_date=None, timezone=None, theme=None)¶
The report object.
This class is not meant to be instantiated directly; instead, use the
ReportFactoryclass to generate an instance.
the report title.
number of days.
the start date.
the end date.
the timezone name. Defaults to the system timezone.
- class kpireport.report.ReportFactory(config)¶
A factory class for building and executing an entire report.
Once you have a report parsed from its YAML Configuration file, you can execute the report like so:
the (parsed) configuration YAML file.
the output formats that any report can target.
Render all Views in the report and output using the output driver.
This will send the report using all configured output drivers! Disable any output drivers you don’t wish to send to during testing.
- class kpireport.report.Theme(num_columns=6, column_width=86, padding_width=20, theme_dir=None, ui_colors=None, error_colors=None, success_colors=None, series_colors=None, heading_font=None)¶
The report theme options.
the number of columns in the report grid. (Default 6)
the width of each column, in pixels. (Default 86)
the width of the horizontal padding at the report edges (Default 20)
a directory where additional templates can be found. These templates will override the default templates of the same name, and can be used to alter the overall report appearance.
a list of user interface colors. This is expected to be a 5-tuple of (text color, lighter text color, dark bg color, bg accent, bg color)
a list of error colors used when views render an error vs. success state. This is expected to be a 2-tuple of (dark, light).
a list of success colors used when views render an error vs. success state. This is expected to be a 2-tuple of (dark, light).
a list of series colors. There can be as many or as few series colors in the theme; you just want to ensure you can handle whatever needs you have for plotting or displaying data in charts or graphs such that series can be identified clearly.
A CSS font-family declaration, which will define how the headings are styled. (Default “Helvetica, Arial, sans-serif”). Note that due to Jinja escaping rules, this does not like embedded quotes. Quotes are not required even when a typeface has a space in the name, so they are safe to simply omit.