plainbox.impl.exporter.html

HTML exporter for human consumption

Warning

THIS MODULE DOES NOT HAVE A STABLE PUBLIC API

class plainbox.impl.exporter.html.HTMLResourceInliner[source]

Bases: builtins.object

A helper class to inline resources referenced in an lxml tree.

inline_resources(document_tree)[source]

Replace references to external resources by an in-place (inlined) representation of each resource.

Currently images, stylesheets and scripts are inlined.

Only local (i.e. file) resources/locations are supported. If a non-local resource is requested for inlining, it will be removed (replaced by a blank string), with the goal that the resulting lxml tree will not reference any unreachable resources.

Parameters:document_tree – lxml tree to process.
Returns:lxml tree with some elements replaced by their inlined representation.
class plainbox.impl.exporter.html.HTMLSessionStateExporter(option_list=None, system_id=None, timestamp=None, client_version=None, client_name='plainbox')[source]

Bases: plainbox.impl.exporter.xml.XMLSessionStateExporter

Session state exporter creating HTML documents.

It basically applies an xslt to the XMLSessionStateExporter output, and then inlines some resources to produce a monolithic report in a single file.

NS = '2013.com.canonical.certification::'
OPTION_CLIENT_NAME = 'client-name'
OPTION_FLATTEN_IO_LOG = 'flatten-io-log'
OPTION_SQUASH_IO_LOG = 'squash-io-log'
OPTION_WITH_ATTACHMENTS = 'with-attachments'
OPTION_WITH_CATEGORY_MAP = 'with-category-map'
OPTION_WITH_CERTIFICATION_STATUS = 'with-certification-status'
OPTION_WITH_COMMENTS = 'with-comments'
OPTION_WITH_DESIRED_JOB_LIST = 'with-job-list'
OPTION_WITH_IO_LOG = 'with-io-log'
OPTION_WITH_JOB_DEFS = 'with-job-defs'
OPTION_WITH_JOB_HASH = 'with-job-hash'
OPTION_WITH_JOB_LIST = 'with-job-list'
OPTION_WITH_JOB_VIA = 'with-job-via'
OPTION_WITH_RESOURCE_MAP = 'with-resource-map'
OPTION_WITH_RUN_LIST = 'with-run-list'
SUPPORTED_OPTION_LIST = ('client-name', 'with-certification-status')
dump(data, stream)[source]

Public method to dump the HTML report to a stream

dump_etree(root, stream, xslt_template, template_substitutions)[source]

Dumps the given lxml root tree into the given stream, by applying the provided xslt. If template_substitutions is provided, the xslt will first be processed as a string.Template with those substitutions.

Parameters:
  • root – lxml root element of tree to process.
  • stream – Byte stream into which to dump the resulting output.
  • xslt_template – String containing an xslt with which to process the lxml tree to output the desired document type.
  • template_substitutions – Dictionary with substitutions for variables which may be in the xslt_template.
get_option_value(option)

Returns the value assigned to an option.

get_resource(data, partial_id)

Get resource with the specified partial_id

Parameters:
  • data – data obtained from get_session_data_subset()
  • partial_id – partial identifier of the resuorce job
Returns:

List of resource objects or None. Does not return empty lists.

get_root_element(data)

Get the XML element of the document exported from the given data

get_session_data_subset(session)

Compute a subset of session data.

The subset of the data that should be saved may depend on a particular saver class and options selected by the user.

Must return a collection that can be handled by dump(). Special care must be taken when processing io_log (and in the future, attachments) as those can be arbitrarily large.

set_option_value(option, value=True)

assigns a value to an option. If no value is given, it just “sets” the option to True

supported_option_list = ('client-name', 'with-certification-status')

Previous topic

plainbox.impl.exporter – shared code for session state exporters

Next topic

plainbox.impl.exporter.json – JSON exporter

This Page