<commit_before># -*- coding: utf-8 -*-
#/***************************************************************************
# Irmt
#                                 A QGIS plugin
# OpenQuake Integrated Risk Modelling Toolkit
#                              -------------------
#        begin                : 2015-03-27
#        copyright            : (C) 2015 by GEM Foundation
#        email                : <EMAIL>
# ***************************************************************************/
#
# OpenQuake is free software: you can redistribute it and/or modify it
# under the terms of the GNU Affero General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# OpenQuake is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with OpenQuake.  If not, see <http://www.gnu.org/licenses/>.

# Part of this code was taken and re-adapted from
# https://github.com/boundlessgeo/suite-qgis-plugin/blob/master/src/opengeo/qgis/sldadapter.py
# methods to convert the SLD produced by GeoServer (1.0) to the SLD produced
# by QGIS (1.1), and also the other way round. This is a quick and dirty
# solution until both programs support the same specification

import re
import os
from qgis.PyQt.QtCore import Qt
from qgis.PyQt.QtXml import *
from qgis.core import *

SIZE_FACTOR = 4
RASTER_SLD_TEMPLATE = (
    '<?xml version="1.0"?>'
    '<sld:StyledLayerDescriptor xmlns="http://www.opengis.net/sld"'
    ' xmlns:sld="http://www.opengis.net/sld"'
    ' xmlns:ogc="http://www.opengis.net/ogc"'
    ' xmlns:gml="http://www.opengis.''net/gml" version="1.0.0">'
    '<sld:NamedLayer>'
    '<sld:Name>STYLE_NAME</sld:Name>'
    '<sld:UserStyle>'
    '<sld:Name>STYLE_NAME</sld:Name>'
    '<sld:Title/>'
    '<sld:FeatureTypeStyle>'
    # '<sld:Name>name</sld:Name>'
    '<sld:Rule>'
    # '<sld:Name>Single symbol</sld:Name>'
    '<RasterSymbolizer>'
    'SYMBOLIZER_CODE'
    '</RasterSymbolizer>'
    '</sld:Rule>'
    '</sld:FeatureTypeStyle>'
    '</sld:UserStyle>'
    '</sld:NamedLayer>'
    '</sld:StyledLayerDescriptor>')


def adaptQgsToGs(sld, layer):<commit_msg>removed import *<commit_after># -*- coding: utf-8 -*-
#/***************************************************************************
# Irmt
#                                 A QGIS plugin
# OpenQuake Integrated Risk Modelling Toolkit
#                              -------------------
#        begin                : 2015-03-27
#        copyright            : (C) 2015 by GEM Foundation
#        email                : <EMAIL>
# ***************************************************************************/
#
# OpenQuake is free software: you can redistribute it and/or modify it
# under the terms of the GNU Affero General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# OpenQuake is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with OpenQuake.  If not, see <http://www.gnu.org/licenses/>.

# Part of this code was taken and re-adapted from
# https://github.com/boundlessgeo/suite-qgis-plugin/blob/master/src/opengeo/qgis/sldadapter.py
# methods to convert the SLD produced by GeoServer (1.0) to the SLD produced
# by QGIS (1.1), and also the other way round. This is a quick and dirty
# solution until both programs support the same specification

import re
import os
from qgis.PyQt.QtCore import Qt
from qgis.PyQt.QtXml import (QDomDocument, )
from qgis.core import (QgsSingleBandGrayRenderer, QgsExpression, QgsOgcUtils, QgsSingleBandPseudoColorRenderer)

SIZE_FACTOR = 4
RASTER_SLD_TEMPLATE = (
    '<?xml version="1.0"?>'
    '<sld:StyledLayerDescriptor xmlns="http://www.opengis.net/sld"'
    ' xmlns:sld="http://www.opengis.net/sld"'
    ' xmlns:ogc="http://www.opengis.net/ogc"'
    ' xmlns:gml="http://www.opengis.''net/gml" version="1.0.0">'
    '<sld:NamedLayer>'
    '<sld:Name>STYLE_NAME</sld:Name>'
    '<sld:UserStyle>'
    '<sld:Name>STYLE_NAME</sld:Name>'
    '<sld:Title/>'
    '<sld:FeatureTypeStyle>'
    # '<sld:Name>name</sld:Name>'
    '<sld:Rule>'
    # '<sld:Name>Single symbol</sld:Name>'
    '<RasterSymbolizer>'
    'SYMBOLIZER_CODE'
    '</RasterSymbolizer>'
    '</sld:Rule>'
    '</sld:FeatureTypeStyle>'
    '</sld:UserStyle>'
    '</sld:NamedLayer>'
    '</sld:StyledLayerDescriptor>')


def adaptQgsToGs(sld, layer):
{'fraction_non_alphanumeric': 0.1860986547085202, 'fraction_numerical': 0.00978393803505911, 'mean_word_length': 3.2781168265039233, 'pattern_counts': {'":': 0, '<': 51, '<?xml version=': 2, '>': 51, 'https://': 2, 'lorem ipsum': 0, 'www.': 10, 'xml': 10}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3839804', 'n_tokens_mistral': 1581, 'n_tokens_neox': 1524, 'n_words': 430}