Reporting Interfaces

The exosphere.reporting module provides interfaces for generating reports in various formats, including HTML, Markdown, and plain text. It leverages the Jinja2 templating engine.

It is also responsible for returning the JSON representation of Host objects.

Reporting module

This module provides functionality to render reports in various formats using Jinja2 templates.

class exosphere.reporting.OutputFormat(*values)

Bases: str, Enum

Available output formats for reports

html = 'html'
json = 'json'
markdown = 'markdown'
text = 'text'
class exosphere.reporting.ReportRenderer

Bases: object

Renders reports in various formats using Jinja2 templates.

The core of the reporting system, handles setup of the Jinja2 environment, loading templates, and rendering them with provided data.

render_html(hosts: list[Host], hosts_count: int, report_type: ReportType, report_scope: ReportScope, navigation: bool = True, **kwargs: Any) str

Render hosts data report as HTML.

Parameters:
  • hosts – List of Host objects to include in the report

  • hosts_count – Total number of hosts selected for the report

  • navigation – Whether to include the quick navigation section

  • report_type – Type of report (full, updates only, security only)

  • report_scope – Scope of the report (complete or filtered)

  • kwargs – Additional context variables for the template

Returns:

Rendered HTML template string

render_json(hosts: list[Host], report_type: ReportType, **kwargs: Any) str

Render hosts data report as JSON.

Does not involve any template, simply uses json.dumps on Host.to_dict() under the hood for the informational properties

Elides optional fields (like description) when empty/None for cleaner JSON. Discovery fields (os, flavor, etc.) are always present, null if undiscovered.

kwargs are accepted for interface consistency but ignored.

Parameters:
  • hosts – List of Host objects to include in the report

  • report_type – Type of report (full, updates only, security only)

  • kwargs – Additional context variables (not used in JSON rendering)

Returns:

JSON string representation of the hosts data

render_markdown(hosts: list[Host], hosts_count: int, report_type: ReportType, report_scope: ReportScope, **kwargs: Any) str

Render hosts data report as Markdown.

Parameters:
  • hosts – List of Host objects to include in the report

  • hosts_count – Total number of hosts selected for the report

  • report_scope – Scope of the report (complete or filtered)

  • report_type – Type of report (full, updates only, security only)

  • kwargs – Additional context variables for the template

Returns:

Rendered Markdown template string

render_text(hosts: list[Host], hosts_count: int, report_type: ReportType, report_scope: ReportScope, **kwargs: Any) str

Render hosts data report as plain text.

Parameters:
  • hosts – List of Host objects to include in the report

  • hosts_count – Total number of hosts selected for the report

  • report_scope – Scope of the report (complete or filtered)

  • report_type – Type of report (full, updates only, security only)

  • kwargs – Additional context variables for the template

Returns:

Rendered plain text template string

setup_jinja_environment(text: bool) Environment

Setup Jinja2 environment with templates from the package.

Configures autoescaping, global functions, and custom filters.

Parameters:

text – Turns on trim_blocks and lstrip_blocks for text templates

Returns:

Configured Jinja2 Environment

class exosphere.reporting.ReportScope(*values)

Bases: str, Enum

Scope of the report

complete = 'complete'
filtered = 'filtered'
class exosphere.reporting.ReportType(*values)

Bases: str, Enum

Available report types

full = 'Full Report'
security_only = 'Security Only Report'
updates_only = 'Updates Only Report'