Output driver

Module: kpireport.output

class kpireport.output.OutputDriver(report: kpireport.report.Report, **kwargs)
report

the current report.

Type

Report

id

the Output driver ID declared in the report configuration.

Type

str

supported_formats

a list of output formats supported by this driver. Defaults to ["md", "html"].

Type

List[str]

can_render(fmt: str) bool

Determine if this driver supports a given output format.

Parameters

fmt (str) – the desired output format.

Returns

whether the output format can be rendered.

Return type

bool

abstract init(**kwargs)

Initialize the output driver from the report configuration.

Parameters

**kwargs – Arbitrary keyword arguments, declared as args in the report configuration.

render_blob_inline(blob: kpireport.view.Blob, fmt=None)

Render a blob file inline in the report output.

Blobs are typically binary image files; many output formats afford some way of displaying them directly, e.g., in HTML via an <img> tag. Each output driver can define how to render a blob inline. An email output driver may implement some way of attaching the image and referencing it in the mail message, while a HTML file output driver may use an <img> tag and link to the file, or perhaps use a data-uri.

This function is used when invoking the blob template filter.

Parameters
  • blob (kpireport.view.Blob) – the Blob to render.

  • fmt (str) – the output format.

Returns

the rendered Blob output.

Return type

str

abstract render_output(content: kpireport.report.Content, blobs)

Render the report content for the target delivery mechanism.

Parameters
  • content (Content) – the report contents.

  • blobs (List[Blob]) – the blobs generated as part of the report.

exception kpireport.output.OutputDriverError