def ordered_expected_layers(self):
        """Get an ordered list of layers according to users input.

        From top to bottom in the legend:
        [
            ('FromCanvas', layer name, full layer URI, QML),
            ('FromAnalysis', layer purpose, layer group, None),
            ...
        ]

        The full layer URI is coming from our helper.

        :return: An ordered list of layers following a structure.
        :rtype: list
        """
        registry = QgsProject.instance()
        layers = []
        count = self.list_layers_in_map_report.count()
        for i in range(count):
            layer = self.list_layers_in_map_report.item(i)
            origin = layer.data(LAYER_ORIGIN_ROLE)
            if origin == FROM_ANALYSIS['key']:
                key = layer.data(LAYER_PURPOSE_KEY_OR_ID_ROLE)
                parent = layer.data(LAYER_PARENT_ANALYSIS_ROLE)
                layers.append((
                    FROM_ANALYSIS['key'],
                    key,
                    parent,
                    None
                ))
            else:
                layer_id = layer.data(LAYER_PURPOSE_KEY_OR_ID_ROLE)
                layer = registry.mapLayer(layer_id)
                style_document = QDomDocument()
                layer.exportNamedStyle(style_document)

                layers.append((
                    FROM_CANVAS['key'],
                    layer.name(),
                    full_layer_uri(layer),
                    style_document.toString()
                ))
        return layers
def ordered_expected_layers ( self ) : registry = QgsProject . instance ( ) layers = [ ] count = self . list_layers_in_map_report . count ( ) for i in range ( count ) : layer = self . list_layers_in_map_report . item ( i ) origin = layer . data ( LAYER_ORIGIN_ROLE ) if origin == FROM_ANALYSIS [ 'key' ] : key = layer . data ( LAYER_PURPOSE_KEY_OR_ID_ROLE ) parent = layer . data ( LAYER_PARENT_ANALYSIS_ROLE ) layers . append ( ( FROM_ANALYSIS [ 'key' ] , key , parent , None ) ) else : layer_id = layer . data ( LAYER_PURPOSE_KEY_OR_ID_ROLE ) layer = registry . mapLayer ( layer_id ) style_document = QDomDocument ( ) layer . exportNamedStyle ( style_document ) layers . append ( ( FROM_CANVAS [ 'key' ] , layer . name ( ) , full_layer_uri ( layer ) , style_document . toString ( ) ) ) return layers
Get an ordered list of layers according to users input.

        From top to bottom in the legend:
        [
            ('FromCanvas', layer name, full layer URI, QML),
            ('FromAnalysis', layer purpose, layer group, None),
            ...
        ]

        The full layer URI is coming from our helper.

        :return: An ordered list of layers following a structure.
        :rtype: list