safe.report.template_composition module

Module as a wrapper for QgsComposition.

Contact : ole.moller.nielsen@gmail.com

Note

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

class safe.report.template_composition.TemplateComposition(template_path=None, map_settings=None)[source]

Bases: object

Class for handling composition using specific template.

..versionadded: 3.0

component_ids[source]

Getter component ids that should exist on the template.

composition[source]

Getter for composition.

load_template()[source]

Load the template to composition.

To load template properly, you need to set the template and the map settings first (and template_substitution if you want to), e.g:

template_composition = TemplateComposition(
template_path=’/template/path’, map_settings=some_map_settings)
substitution_map = {
‘impact-title’: title, ‘date’: date, ‘time’: time, ‘safe-version’: version, ‘disclaimer’: self.disclaimer

} template_composition.template_substitution = substitution_map template_composition.load_template()

or

template_composition = TemplateComposition() template_composition.template_path = ‘/template/path’ template_composition.map_settings = some_map_settings template_composition.load_template()

Raises:LoadingTemplateError
map_settings[source]

Getter for map_settings instance variable.

missing_elements[source]

Getter for missing elements on the template

Returns:Sub list of component_ids missing from composition.
Return type:list
substitution[source]

Getter for template substitution when loading it to composition.

template_path[source]

Getter for template_path instance variable.