(style_json)
return styles_by_file_name
* Creates the style definitions and returns them mapped by filename
    :param style_json:
    :return:
* Creates the style definitions and returns them mapped by filename
    :param style_json:
    :return:
* Creates the style definitions and returns them mapped by filename : param style_json : : return :
def process(style_json):
    """
     * Creates the style definitions and returns them mapped by filename
    :param style_json:
    :return:
    """
    if not isinstance(style_json, dict):
        style_json = json.loads(style_json)

    layers = style_json["layers"]
    styles_by_file_name = {}
    for l in layers:
        if "ref" in l:
            _apply_source_layer(l, layers)
        if "source-layer" not in l:
            continue
        source_layer = l["source-layer"]
        layer_type = l["type"]
        if source_layer:
            if layer_type == "fill":
                geo_type_name = ".polygon"
            elif layer_type == "line":
                geo_type_name = ".linestring"
            elif layer_type == "symbol":
                geo_type_name = ""
            else:
                continue

            file_name = "{}{}.qml".format(source_layer, geo_type_name)
            if file_name not in styles_by_file_name:
                styles_by_file_name[file_name] = {"file_name": file_name, "type": layer_type, "styles": []}
            qgis_styles = get_styles(l)
            filter_expr = None
            if "filter" in l:
                filter_expr = get_qgis_rule(l["filter"])
            for s in qgis_styles:
                s["rule"] = filter_expr
            styles_by_file_name[file_name]["styles"].extend(qgis_styles)

    for layer_name in styles_by_file_name:
        styles = styles_by_file_name[layer_name]["styles"]
        for index, style in enumerate(styles):
            rule = style["rule"]
            name = style["name"]
            zoom = style["zoom_level"]
            styles_with_same_target = list(
                filter(
                    lambda st: st["name"] != name and st["rule"] == rule and zoom and st["zoom_level"] <= zoom,
                    styles[:index],
                )
            )
            groups_by_name = list(groupby(styles_with_same_target, key=lambda st: st["name"]))
            style["rendering_pass"] = len(groups_by_name)

    _add_default_transparency_styles(styles_by_file_name)
    return styles_by_file_name
def process ( style_json ) : if not isinstance ( style_json , dict ) : style_json = json . loads ( style_json ) layers = style_json [ "layers" ] styles_by_file_name = { } for l in layers : if "ref" in l : _apply_source_layer ( l , layers ) if "source-layer" not in l : continue source_layer = l [ "source-layer" ] layer_type = l [ "type" ] if source_layer : if layer_type == "fill" : geo_type_name = ".polygon" elif layer_type == "line" : geo_type_name = ".linestring" elif layer_type == "symbol" : geo_type_name = "" else : continue file_name = "{}{}.qml" . format ( source_layer , geo_type_name ) if file_name not in styles_by_file_name : styles_by_file_name [ file_name ] = { "file_name" : file_name , "type" : layer_type , "styles" : [ ] } qgis_styles = get_styles ( l ) filter_expr = None if "filter" in l : filter_expr = get_qgis_rule ( l [ "filter" ] ) for s in qgis_styles : s [ "rule" ] = filter_expr styles_by_file_name [ file_name ] [ "styles" ] . extend ( qgis_styles ) for layer_name in styles_by_file_name : styles = styles_by_file_name [ layer_name ] [ "styles" ] for index , style in enumerate ( styles ) : rule = style [ "rule" ] name = style [ "name" ] zoom = style [ "zoom_level" ] styles_with_same_target = list ( filter ( lambda st : st [ "name" ] != name and st [ "rule" ] == rule and zoom and st [ "zoom_level" ] <= zoom , styles [ : index ] , ) ) groups_by_name = list ( groupby ( styles_with_same_target , key = lambda st : st [ "name" ] ) ) style [ "rendering_pass" ] = len ( groups_by_name ) _add_default_transparency_styles ( styles_by_file_name ) return styles_by_file_name