sasctl.services.report_images#

class sasctl._services.report_images.ReportImages[source]#

Bases: Service

Delivers SVG images representing elements of a report.

The images are suitable to the current user, taking row-level-permissions and other factors into consideration.

LOD_HIGH = 2#

Renders all of the components of content.

LOD_LOW = 0#

Renders the content with minimal details for creating thumbnails.

LOD_MEDIUM = 1#

Renders the primary components of the content.

classmethod get_images(report, section=None, elements=None, size=None, lod=None)[source]#

Render images of reports or report sections.

Report contents are sized and arranged dynamically to accommodate browser viewing. Some or all of these contents may be rendered at any time to produce an SVG image of the desired size. A rendering job will automatically be created and the resulting images returned upon job completion.

Parameters:
  • report (str or RestObj) – Report to retrieve images from specified as either a URI or a RestObj instance as returned from reports.get_report.

  • section (int, optional) – A specific report section to retrieve, specified by a zero-based index. If not specified, all sections will be returned as separate images.

  • elements (List[Tuple[str, str]], optional) – Iterable of tuples containing the element name and the size of the element when rendered.

  • size (str or Tuple[int, int], optional) – Size (in pixels) of the resulting images. Ignored if elements is specified.

  • lod (LOD, optional) – Level of detail of the rendered image(s). Defaults to LOD.HIGH.

Returns:

List[bytes] – List of binary strings, each representing one SVG image.

Examples

Render a single element of a report

>>> from sasctl.services import reports
>>> report = reports.get_report('Parrot Status')
>>> report_images.get_images(report, elements=('Norwegian Blue', '640x480'))
[b'<svg>beautiful_plummage</svg>']

Render each page of the report

>>> from sasctl.services import reports
>>> report = reports.get_report('Parrot Status')
>>> report_images.get_images(report)
[b'<svg>Customer Complaints</svg>', b'<svg>Deceased</svg>']

Render the 2nd page of a report

>>> from sasctl.services import reports
>>> report = reports.get_report('Parrot Status')
>>> report_images.get_images(report, section=1)
[b'<svg>Deceased</svg>']
classmethod get_images_async(report, section=None, elements=None, size=None, lod=None)[source]#

Create a job to render images of reports or report sections.

Report contents are sized and arranged dynamically to accommodate browser viewing. Some or all of these contents may be rendered at any time to produce an SVG image of the desired size. This is done by creating a render job which will create the requested images and return their download links.

Parameters:
  • report (str or RestObj) – Report to retrieve images from specified as either a URI or a RestObj instance as returned from reports.get_report.

  • section (int, optional) – A specific report section to retrieve, specified by a zero-based index. If not specified, all sections will be returned as separate images.

  • elements (List[Tuple[str, str]], optional) – Iterable of tuples containing the element name and the size of the element when rendered.

  • size (str or Tuple[int, int], optional) – Size (in pixels) of the resulting images. Ignored if elements is specified.

  • lod (int, optional) – Level of detail of the rendered image(s). Defaults to HIGH.

Returns:

RestObj – The render job