diff --git a/python/plugins/grassprovider/CMakeLists.txt b/python/plugins/grassprovider/CMakeLists.txt index a454e9e41cc..e71774d3d4b 100644 --- a/python/plugins/grassprovider/CMakeLists.txt +++ b/python/plugins/grassprovider/CMakeLists.txt @@ -1,6 +1,6 @@ file(GLOB PY_FILES *.py) list(FILTER PY_FILES EXCLUDE REGEX ".*description_to_json.py") -file(GLOB OTHER_FILES grass7.txt metadata.txt) +file(GLOB OTHER_FILES grass.txt metadata.txt) execute_process( COMMAND ${Python_EXECUTABLE} -m grassprovider.description_to_json ${CMAKE_CURRENT_SOURCE_DIR}/description ${CMAKE_CURRENT_SOURCE_DIR}/description/algorithms.json diff --git a/python/plugins/grassprovider/__init__.py b/python/plugins/grassprovider/__init__.py index b2ad6ba1750..9af45507fb6 100644 --- a/python/plugins/grassprovider/__init__.py +++ b/python/plugins/grassprovider/__init__.py @@ -21,5 +21,5 @@ __copyright__ = '(C) 2021, Alexander Bruy' def classFactory(iface): - from grassprovider.GrassProviderPlugin import GrassProviderPlugin + from grassprovider.grass_plugin import GrassProviderPlugin return GrassProviderPlugin() diff --git a/python/plugins/grassprovider/ext/i.py b/python/plugins/grassprovider/ext/i.py index fc283b94491..3124495c6d2 100644 --- a/python/plugins/grassprovider/ext/i.py +++ b/python/plugins/grassprovider/ext/i.py @@ -21,7 +21,7 @@ __copyright__ = '(C) 2016, Médéric Ribreux' import os from processing.tools.system import (isWindows, getTempFilename) -from grassprovider.Grass7Utils import Grass7Utils +from grassprovider.grass_utils import GrassUtils from qgis.PyQt.QtCore import QDir from qgis.core import QgsProcessingParameterString from qgis.core import QgsMessageLog @@ -121,7 +121,7 @@ def importSigFile(alg, group, subgroup, src, sigDir='sig'): internal GRASSDB folder """ shortSigFile = os.path.basename(src) - interSig = os.path.join(Grass7Utils.grassMapsetFolder(), + interSig = os.path.join(GrassUtils.grassMapsetFolder(), 'PERMANENT', 'group', group, 'subgroup', subgroup, sigDir, shortSigFile) copyFile(alg, src, interSig) @@ -134,7 +134,7 @@ def exportSigFile(alg, group, subgroup, dest, sigDir='sig'): to final destination """ shortSigFile = os.path.basename(dest) - interSig = os.path.join(Grass7Utils.grassMapsetFolder(), + interSig = os.path.join(GrassUtils.grassMapsetFolder(), 'PERMANENT', 'group', group, 'subgroup', subgroup, sigDir, shortSigFile) moveFile(alg, interSig, dest) @@ -155,7 +155,7 @@ def exportInputRasters(alg, parameters, context, rasterDic): fileName = os.path.normpath( alg.parameterAsOutputLayer(parameters, outputName, context)) grassName = alg.exportedLayers[inputName] - outFormat = Grass7Utils.getRasterFormatFromFilename(fileName) + outFormat = GrassUtils.getRasterFormatFromFilename(fileName) alg.exportRasterLayer(grassName, fileName, True, outFormat, createOpt, metaOpt) diff --git a/python/plugins/grassprovider/ext/i_pansharpen.py b/python/plugins/grassprovider/ext/i_pansharpen.py index e6808d6b601..056d3e32361 100644 --- a/python/plugins/grassprovider/ext/i_pansharpen.py +++ b/python/plugins/grassprovider/ext/i_pansharpen.py @@ -22,7 +22,7 @@ __copyright__ = '(C) 2016, Médéric Ribreux' import os from qgis.core import QgsProcessingParameterString from processing.tools.system import getTempFilename -from grassprovider.Grass7Utils import Grass7Utils +from grassprovider.grass_utils import GrassUtils def processCommand(alg, parameters, context, feedback): @@ -41,5 +41,5 @@ def processOutputs(alg, parameters, context, feedback): for channel in ['red', 'green', 'blue']: fileName = alg.parameterAsOutputLayer(parameters, '{}output'.format(channel), context) grassName = '{}_{}'.format(outputName, channel) - outFormat = Grass7Utils.getRasterFormatFromFilename(fileName) + outFormat = GrassUtils.getRasterFormatFromFilename(fileName) alg.exportRasterLayer(grassName, fileName, True, outFormat, createOpt, metaOpt) diff --git a/python/plugins/grassprovider/ext/r_blend_rgb.py b/python/plugins/grassprovider/ext/r_blend_rgb.py index 954128f0403..2e763d5412c 100644 --- a/python/plugins/grassprovider/ext/r_blend_rgb.py +++ b/python/plugins/grassprovider/ext/r_blend_rgb.py @@ -20,7 +20,7 @@ __date__ = 'February 2016' __copyright__ = '(C) 2016, Médéric Ribreux' import os -from grassprovider.Grass7Utils import Grass7Utils +from grassprovider.grass_utils import GrassUtils def processInputs(alg, parameters, context, feedback): @@ -47,6 +47,6 @@ def processOutputs(alg, parameters, context, feedback): for color in colors: fileName = os.path.normpath( alg.parameterAsOutputLayer(parameters, 'output_{}'.format(color), context)) - outFormat = Grass7Utils.getRasterFormatFromFilename(fileName) + outFormat = GrassUtils.getRasterFormatFromFilename(fileName) alg.exportRasterLayer('blended.{}'.format(color[0]), fileName, True, outFormat, createOpt, metaOpt) diff --git a/python/plugins/grassprovider/ext/r_category.py b/python/plugins/grassprovider/ext/r_category.py index 7b134d78f1e..1f9e0476468 100644 --- a/python/plugins/grassprovider/ext/r_category.py +++ b/python/plugins/grassprovider/ext/r_category.py @@ -20,7 +20,7 @@ __date__ = 'February 2016' __copyright__ = '(C) 2016, Médéric Ribreux' from processing.tools.system import getTempFilename -from grassprovider.Grass7Utils import Grass7Utils +from grassprovider.grass_utils import GrassUtils def checkParameterValuesBeforeExecuting(alg, parameters, context): @@ -72,7 +72,7 @@ def processOutputs(alg, parameters, context, feedback): # We need to export the raster with all its bands and its color table fileName = alg.parameterAsOutputLayer(parameters, 'output', context) - outFormat = Grass7Utils.getRasterFormatFromFilename(fileName) + outFormat = GrassUtils.getRasterFormatFromFilename(fileName) grassName = alg.exportedLayers['map'] alg.exportRasterLayer(grassName, fileName, True, outFormat, createOpt, metaOpt) diff --git a/python/plugins/grassprovider/ext/r_colors.py b/python/plugins/grassprovider/ext/r_colors.py index 72c55b39186..e0e7baf28db 100644 --- a/python/plugins/grassprovider/ext/r_colors.py +++ b/python/plugins/grassprovider/ext/r_colors.py @@ -20,7 +20,7 @@ __date__ = 'February 2016' __copyright__ = '(C) 2016, Médéric Ribreux' import os -from grassprovider.Grass7Utils import Grass7Utils +from grassprovider.grass_utils import GrassUtils from processing.tools.system import getTempFilename @@ -77,6 +77,6 @@ def processOutputs(alg, parameters, context, feedback): for idx, raster in enumerate(rasters): rasterName = 'map_{}'.format(idx) fileName = os.path.join(outputDir, rasterName) - outFormat = Grass7Utils.getRasterFormatFromFilename(fileName) + outFormat = GrassUtils.getRasterFormatFromFilename(fileName) alg.exportRasterLayer(alg.exportedLayers[rasterName], fileName, True, outFormat, createOpt, metaOpt) diff --git a/python/plugins/grassprovider/ext/r_colors_stddev.py b/python/plugins/grassprovider/ext/r_colors_stddev.py index 167afba0ffe..fd3602af539 100644 --- a/python/plugins/grassprovider/ext/r_colors_stddev.py +++ b/python/plugins/grassprovider/ext/r_colors_stddev.py @@ -19,7 +19,7 @@ __author__ = 'Médéric Ribreux' __date__ = 'February 2016' __copyright__ = '(C) 2016, Médéric Ribreux' -from grassprovider.Grass7Utils import Grass7Utils +from grassprovider.grass_utils import GrassUtils def processInputs(alg, parameters, context, feedback): @@ -43,7 +43,7 @@ def processOutputs(alg, parameters, context, feedback): # We need to export the raster with all its bands and its color table fileName = alg.parameterAsOutputLayer(parameters, 'output', context) - outFormat = Grass7Utils.getRasterFormatFromFilename(fileName) + outFormat = GrassUtils.getRasterFormatFromFilename(fileName) grassName = alg.exportedLayers['map'] alg.exportRasterLayer(grassName, fileName, True, outFormat, createOpt, metaOpt) diff --git a/python/plugins/grassprovider/ext/r_mask_rast.py b/python/plugins/grassprovider/ext/r_mask_rast.py index ba3420e6bde..6d36a2eede9 100644 --- a/python/plugins/grassprovider/ext/r_mask_rast.py +++ b/python/plugins/grassprovider/ext/r_mask_rast.py @@ -19,7 +19,7 @@ __author__ = 'Médéric Ribreux' __date__ = 'February 2016' __copyright__ = '(C) 2016, Médéric Ribreux' -from grassprovider.Grass7Utils import Grass7Utils +from grassprovider.grass_utils import GrassUtils def processCommand(alg, parameters, context, feedback): @@ -34,7 +34,7 @@ def processOutputs(alg, parameters, context, feedback): # We need to export the raster with all its bands and its color table fileName = alg.parameterAsOutputLayer(parameters, 'output', context) - outFormat = Grass7Utils.getRasterFormatFromFilename(fileName) + outFormat = GrassUtils.getRasterFormatFromFilename(fileName) grassName = alg.exportedLayers['input'] alg.exportRasterLayer(grassName, fileName, True, outFormat, createOpt, metaOpt) diff --git a/python/plugins/grassprovider/ext/r_mask_vect.py b/python/plugins/grassprovider/ext/r_mask_vect.py index d3b9b7a97f3..40e5fb2c3f7 100644 --- a/python/plugins/grassprovider/ext/r_mask_vect.py +++ b/python/plugins/grassprovider/ext/r_mask_vect.py @@ -19,7 +19,7 @@ __author__ = 'Médéric Ribreux' __date__ = 'February 2016' __copyright__ = '(C) 2016, Médéric Ribreux' -from grassprovider.Grass7Utils import Grass7Utils +from grassprovider.grass_utils import GrassUtils def processCommand(alg, parameters, context, feedback): @@ -34,7 +34,7 @@ def processOutputs(alg, parameters, context, feedback): # We need to export the raster with all its bands and its color table fileName = alg.parameterAsOutputLayer(parameters, 'output', context) - outFormat = Grass7Utils.getRasterFormatFromFilename(fileName) + outFormat = GrassUtils.getRasterFormatFromFilename(fileName) grassName = alg.exportedLayers['input'] alg.exportRasterLayer(grassName, fileName, True, outFormat, createOpt, metaOpt) diff --git a/python/plugins/grassprovider/ext/r_proj.py b/python/plugins/grassprovider/ext/r_proj.py index 3e258c84190..46d0f754930 100644 --- a/python/plugins/grassprovider/ext/r_proj.py +++ b/python/plugins/grassprovider/ext/r_proj.py @@ -21,7 +21,7 @@ __copyright__ = '(C) 2017, Médéric Ribreux' from qgis.core import QgsProcessingParameterString from processing.tools.system import isWindows -from grassprovider.Grass7Utils import Grass7Utils +from grassprovider.grass_utils import GrassUtils def processInputs(alg, parameters, context, feedback): @@ -29,7 +29,7 @@ def processInputs(alg, parameters, context, feedback): layer = alg.parameterAsLayer(parameters, 'input', context) # Creates a new location with this Crs - wkt_file_name = Grass7Utils.exportCrsWktToFile(layer.crs(), context) + wkt_file_name = GrassUtils.exportCrsWktToFile(layer.crs(), context) newLocation = 'newProj{}'.format(alg.uniqueSuffix) alg.commands.append('g.proj wkt="{}" location={}'.format( wkt_file_name, newLocation)) @@ -47,7 +47,7 @@ def processInputs(alg, parameters, context, feedback): # Grab the projected Crs crs = alg.parameterAsCrs(parameters, 'crs', context) - wkt_file_name = Grass7Utils.exportCrsWktToFile(crs, context) + wkt_file_name = GrassUtils.exportCrsWktToFile(crs, context) alg.commands.append('g.proj -c wkt="{}"'.format(wkt_file_name)) # Remove crs parameter diff --git a/python/plugins/grassprovider/ext/r_series_interp.py b/python/plugins/grassprovider/ext/r_series_interp.py index 07654e4fc70..0135c46d3f5 100644 --- a/python/plugins/grassprovider/ext/r_series_interp.py +++ b/python/plugins/grassprovider/ext/r_series_interp.py @@ -20,7 +20,7 @@ __date__ = 'February 2016' __copyright__ = '(C) 2016, Médéric Ribreux' import os -from grassprovider.Grass7Utils import Grass7Utils +from grassprovider.grass_utils import GrassUtils def checkParameterValuesBeforeExecuting(alg, parameters, context): @@ -65,6 +65,6 @@ def processOutputs(alg, parameters, context, feedback): for out in outs: # We need to export the raster with all its bands and its color table fileName = os.path.join(outputDir, out) - outFormat = Grass7Utils.getRasterFormatFromFilename(fileName) + outFormat = GrassUtils.getRasterFormatFromFilename(fileName) alg.exportRasterLayer(out, fileName, True, outFormat, createOpt, metaOpt) diff --git a/python/plugins/grassprovider/ext/r_statistics.py b/python/plugins/grassprovider/ext/r_statistics.py index 4f0f823853c..11f403c7078 100644 --- a/python/plugins/grassprovider/ext/r_statistics.py +++ b/python/plugins/grassprovider/ext/r_statistics.py @@ -20,7 +20,7 @@ __date__ = 'September 2017' __copyright__ = '(C) 2017, Médéric Ribreux' from qgis.core import QgsProcessingParameterString -from grassprovider.Grass7Utils import Grass7Utils +from grassprovider.grass_utils import GrassUtils def processCommand(alg, parameters, context, feedback): @@ -47,6 +47,6 @@ def processOutputs(alg, parameters, context, feedback): grassName = 'correctedoutput{}'.format(alg.uniqueSuffix) fileName = alg.parameterAsOutputLayer( parameters, 'routput', context) - outFormat = Grass7Utils.getRasterFormatFromFilename(fileName) + outFormat = GrassUtils.getRasterFormatFromFilename(fileName) alg.exportRasterLayer(grassName, fileName, True, outFormat, createOpt, metaOpt) diff --git a/python/plugins/grassprovider/ext/r_stats_quantile_rast.py b/python/plugins/grassprovider/ext/r_stats_quantile_rast.py index e48a09fa3ce..ccd8e4ca631 100644 --- a/python/plugins/grassprovider/ext/r_stats_quantile_rast.py +++ b/python/plugins/grassprovider/ext/r_stats_quantile_rast.py @@ -21,7 +21,7 @@ __copyright__ = '(C) 2016, Médéric Ribreux' import os from qgis.core import QgsProcessingParameterString -from grassprovider.Grass7Utils import Grass7Utils +from grassprovider.grass_utils import GrassUtils def processCommand(alg, parameters, context, feedback): @@ -49,6 +49,6 @@ def processOutputs(alg, parameters, context, feedback): # We need to export each of the output for output in outputs: fileName = os.path.join(outputDir, output) - outFormat = Grass7Utils.getRasterFormatFromFilename(fileName) + outFormat = GrassUtils.getRasterFormatFromFilename(fileName) alg.exportRasterLayer(output, fileName, True, outFormat, createOpt, metaOpt) diff --git a/python/plugins/grassprovider/ext/r_tileset.py b/python/plugins/grassprovider/ext/r_tileset.py index c9271a877df..15d8c8deb90 100644 --- a/python/plugins/grassprovider/ext/r_tileset.py +++ b/python/plugins/grassprovider/ext/r_tileset.py @@ -19,11 +19,11 @@ __author__ = 'Médéric Ribreux' __date__ = 'October 2017' __copyright__ = '(C) 2017, Médéric Ribreux' -from grassprovider.Grass7Utils import Grass7Utils +from grassprovider.grass_utils import GrassUtils def processOutputs(alg, parameters, context, feedback): crs = alg.parameterAsCrs(parameters, 'sourceproj', context) - wkt_file_name = Grass7Utils.exportCrsWktToFile(crs, context) + wkt_file_name = GrassUtils.exportCrsWktToFile(crs, context) alg.commands.insert(0, 'g.proj -c wkt="{}"'.format(wkt_file_name)) diff --git a/python/plugins/grassprovider/ext/v_proj.py b/python/plugins/grassprovider/ext/v_proj.py index b27895ac301..deb72bd9335 100644 --- a/python/plugins/grassprovider/ext/v_proj.py +++ b/python/plugins/grassprovider/ext/v_proj.py @@ -20,7 +20,7 @@ __date__ = 'November 2017' __copyright__ = '(C) 2017, Médéric Ribreux' from qgis.core import QgsProcessingParameterString -from grassprovider.Grass7Utils import Grass7Utils +from grassprovider.grass_utils import GrassUtils def processInputs(alg, parameters, context, feedback): @@ -30,7 +30,7 @@ def processInputs(alg, parameters, context, feedback): layerCrs = layer.crs().toProj() # Creates a new location with this Crs - wkt_file_name = Grass7Utils.exportCrsWktToFile(layer.crs(), context) + wkt_file_name = GrassUtils.exportCrsWktToFile(layer.crs(), context) newLocation = 'newProj{}'.format(alg.uniqueSuffix) alg.commands.append('g.proj wkt="{}" location={}'.format( wkt_file_name, newLocation)) @@ -48,7 +48,7 @@ def processInputs(alg, parameters, context, feedback): # Grab the projected Crs crs = alg.parameterAsCrs(parameters, 'crs', context) - wkt_file_name = Grass7Utils.exportCrsWktToFile(crs, context) + wkt_file_name = GrassUtils.exportCrsWktToFile(crs, context) alg.commands.append('g.proj -c wkt="{}"'.format(wkt_file_name)) # Remove crs parameter diff --git a/python/plugins/grassprovider/ext/v_rectify.py b/python/plugins/grassprovider/ext/v_rectify.py index 3e0f90dbf94..ada7bbf1bcf 100644 --- a/python/plugins/grassprovider/ext/v_rectify.py +++ b/python/plugins/grassprovider/ext/v_rectify.py @@ -20,7 +20,7 @@ __date__ = 'March 2016' __copyright__ = '(C) 2016, Médéric Ribreux' import os -from grassprovider.Grass7Utils import Grass7Utils +from grassprovider.grass_utils import GrassUtils from processing.tools.system import getTempFilename diff --git a/python/plugins/grassprovider/grass7.txt b/python/plugins/grassprovider/grass.txt similarity index 100% rename from python/plugins/grassprovider/grass7.txt rename to python/plugins/grassprovider/grass.txt diff --git a/python/plugins/grassprovider/Grass7Algorithm.py b/python/plugins/grassprovider/grass_algorithm.py similarity index 97% rename from python/plugins/grassprovider/Grass7Algorithm.py rename to python/plugins/grassprovider/grass_algorithm.py index 9facf53e20e..49de7ae8ee6 100644 --- a/python/plugins/grassprovider/Grass7Algorithm.py +++ b/python/plugins/grassprovider/grass_algorithm.py @@ -1,6 +1,6 @@ """ *************************************************************************** - Grass7Algorithm.py + grass_algorithm.py --------------------- Date : February 2015 Copyright : (C) 2014-2015 by Victor Olaya @@ -79,7 +79,7 @@ from processing.core.ProcessingConfig import ProcessingConfig from processing.core.parameters import getParameterFromString from grassprovider.parsed_description import ParsedDescription -from grassprovider.Grass7Utils import Grass7Utils +from grassprovider.grass_utils import GrassUtils from processing.tools.system import isWindows, getTempFilename @@ -87,7 +87,7 @@ pluginPath = os.path.normpath(os.path.join( os.path.split(os.path.dirname(__file__))[0], os.pardir)) -class Grass7Algorithm(QgsProcessingAlgorithm): +class GrassAlgorithm(QgsProcessingAlgorithm): GRASS_OUTPUT_TYPE_PARAMETER = 'GRASS_OUTPUT_TYPE_PARAMETER' GRASS_MIN_AREA_PARAMETER = 'GRASS_MIN_AREA_PARAMETER' GRASS_SNAP_TOLERANCE_PARAMETER = 'GRASS_SNAP_TOLERANCE_PARAMETER' @@ -211,7 +211,7 @@ class Grass7Algorithm(QgsProcessingAlgorithm): return QCoreApplication.translate(context, string) def helpUrl(self): - helpPath = Grass7Utils.grassHelpPath() + helpPath = GrassUtils.grassHelpPath() if helpPath == '': return None @@ -447,7 +447,7 @@ class Grass7Algorithm(QgsProcessingAlgorithm): def processAlgorithm(self, original_parameters, context, feedback): if isWindows(): - path = Grass7Utils.grassPath() + path = GrassUtils.grassPath() if path == '': raise QgsProcessingException( self.tr('GRASS GIS 7 folder is not configured. Please ' @@ -465,11 +465,11 @@ class Grass7Algorithm(QgsProcessingAlgorithm): # If GRASS session has been created outside of this algorithm then # get the list of layers loaded in GRASS otherwise start a new # session - existingSession = Grass7Utils.sessionRunning + existingSession = GrassUtils.sessionRunning if existingSession: - self.exportedLayers = Grass7Utils.getSessionLayers() + self.exportedLayers = GrassUtils.getSessionLayers() else: - Grass7Utils.startGrassSession() + GrassUtils.startGrassSession() # Handle default GRASS parameters self.grabDefaultGrassParameters(parameters, context) @@ -487,17 +487,17 @@ class Grass7Algorithm(QgsProcessingAlgorithm): for line in self.commands: feedback.pushCommandInfo(line) loglines.append(line) - if ProcessingConfig.getSetting(Grass7Utils.GRASS_LOG_COMMANDS): + if ProcessingConfig.getSetting(GrassUtils.GRASS_LOG_COMMANDS): QgsMessageLog.logMessage("\n".join(loglines), self.tr('Processing'), Qgis.MessageLevel.Info) - Grass7Utils.executeGrass(self.commands, feedback, self.outputCommands) + GrassUtils.executeGrass(self.commands, feedback, self.outputCommands) # If the session has been created outside of this algorithm, add # the new GRASS GIS 7 layers to it otherwise finish the session if existingSession: - Grass7Utils.addSessionLayers(self.exportedLayers) + GrassUtils.addSessionLayers(self.exportedLayers) else: - Grass7Utils.endGrassSession() + GrassUtils.endGrassSession() # Return outputs map outputs = {} @@ -801,7 +801,7 @@ class Grass7Algorithm(QgsProcessingAlgorithm): :param destName: force the destination name of the raster. """ if external is None: - external = ProcessingConfig.getSetting(Grass7Utils.GRASS_USE_REXTERNAL) + external = ProcessingConfig.getSetting(GrassUtils.GRASS_USE_REXTERNAL) self.inputLayers.append(layer) self.setSessionProjectionFromLayer(layer, context) if not destName: @@ -829,7 +829,7 @@ class Grass7Algorithm(QgsProcessingAlgorithm): fileName = os.path.normpath(fileName) grassName = '{}{}'.format(name, self.uniqueSuffix) - outFormat = Grass7Utils.getRasterFormatFromFilename(fileName) + outFormat = GrassUtils.getRasterFormatFromFilename(fileName) createOpt = self.parameterAsString(parameters, self.GRASS_RASTER_FORMAT_OPT, context) metaOpt = self.parameterAsString(parameters, self.GRASS_RASTER_FORMAT_META, context) self.exportRasterLayer(grassName, fileName, colorTable, outFormat, createOpt, metaOpt) @@ -850,7 +850,7 @@ class Grass7Algorithm(QgsProcessingAlgorithm): :param createOpt: creation options for format. :param metaOpt: metadata options for export. """ - createOpt = createOpt or Grass7Utils.GRASS_RASTER_FORMATS_CREATEOPTS.get(outFormat) + createOpt = createOpt or GrassUtils.GRASS_RASTER_FORMATS_CREATEOPTS.get(outFormat) for cmd in [self.commands, self.outputCommands]: # Adjust region to layer before exporting @@ -949,7 +949,7 @@ class Grass7Algorithm(QgsProcessingAlgorithm): # TODO: support multiple input formats if external is None: external = ProcessingConfig.getSetting( - Grass7Utils.GRASS_USE_VEXTERNAL) + GrassUtils.GRASS_USE_VEXTERNAL) source_parts = QgsProviderRegistry.instance().decodeUri('ogr', layer.source()) file_path = source_parts.get('path') @@ -1095,7 +1095,7 @@ class Grass7Algorithm(QgsProcessingAlgorithm): Set the projection from the project. We create a WKT definition which is transmitted to Grass """ - if not Grass7Utils.projectionSet and iface: + if not GrassUtils.projectionSet and iface: self.setSessionProjection( iface.mapCanvas().mapSettings().destinationCrs(), context @@ -1106,7 +1106,7 @@ class Grass7Algorithm(QgsProcessingAlgorithm): Set the projection from a QgsVectorLayer. We create a WKT definition which is transmitted to Grass """ - if not Grass7Utils.projectionSet: + if not GrassUtils.projectionSet: self.setSessionProjection(layer.crs(), context) def setSessionProjection(self, crs, context: QgsProcessingContext): @@ -1114,10 +1114,10 @@ class Grass7Algorithm(QgsProcessingAlgorithm): Set the session projection to the specified CRS """ self.destination_crs = crs - file_name = Grass7Utils.exportCrsWktToFile(crs, context) + file_name = GrassUtils.exportCrsWktToFile(crs, context) command = 'g.proj -c wkt="{}"'.format(file_name) self.commands.append(command) - Grass7Utils.projectionSet = True + GrassUtils.projectionSet = True def convertToHtml(self, fileName): # Read HTML contents @@ -1136,7 +1136,7 @@ class Grass7Algorithm(QgsProcessingAlgorithm): f.write('

') def canExecute(self): - message = Grass7Utils.checkGrassIsInstalled() + message = GrassUtils.checkGrassIsInstalled() return not message, message def checkParameterValues(self, parameters, context): diff --git a/python/plugins/grassprovider/GrassProviderPlugin.py b/python/plugins/grassprovider/grass_plugin.py similarity index 89% rename from python/plugins/grassprovider/GrassProviderPlugin.py rename to python/plugins/grassprovider/grass_plugin.py index 1c4473436a8..1f82de63e7f 100644 --- a/python/plugins/grassprovider/GrassProviderPlugin.py +++ b/python/plugins/grassprovider/grass_plugin.py @@ -1,6 +1,6 @@ """ *************************************************************************** - GrassProviderPlugin.py + grass_plugin.py --------------------- Date : June 2021 Copyright : (C) 2021 by Alexander Bruy @@ -23,13 +23,13 @@ __copyright__ = '(C) 2021, Alexander Bruy' from qgis.core import QgsApplication, QgsRuntimeProfiler with QgsRuntimeProfiler.profile('Import GRASS Provider'): - from grassprovider.Grass7AlgorithmProvider import Grass7AlgorithmProvider + from grassprovider.grass_provider import GrassProvider class GrassProviderPlugin: def __init__(self): - self.provider = Grass7AlgorithmProvider() + self.provider = GrassProvider() def initProcessing(self): QgsApplication.processingRegistry().addProvider(self.provider) diff --git a/python/plugins/grassprovider/Grass7AlgorithmProvider.py b/python/plugins/grassprovider/grass_provider.py similarity index 85% rename from python/plugins/grassprovider/Grass7AlgorithmProvider.py rename to python/plugins/grassprovider/grass_provider.py index a18511aa7fe..39cb741863e 100644 --- a/python/plugins/grassprovider/Grass7AlgorithmProvider.py +++ b/python/plugins/grassprovider/grass_provider.py @@ -1,6 +1,6 @@ """ *************************************************************************** - Grass7AlgorithmProvider.py + grass_provider.py --------------------- Date : April 2014 Copyright : (C) 2014 by Victor Olaya @@ -30,11 +30,11 @@ from qgis.core import (Qgis, QgsMessageLog, QgsRuntimeProfiler) from processing.core.ProcessingConfig import (ProcessingConfig, Setting) -from grassprovider.Grass7Utils import Grass7Utils -from grassprovider.Grass7Algorithm import Grass7Algorithm +from grassprovider.grass_utils import GrassUtils +from grassprovider.grass_algorithm import GrassAlgorithm -class Grass7AlgorithmProvider(QgsProcessingProvider): +class GrassProvider(QgsProcessingProvider): def __init__(self): super().__init__() @@ -44,15 +44,15 @@ class Grass7AlgorithmProvider(QgsProcessingProvider): ProcessingConfig.settingIcons[self.name()] = self.icon() ProcessingConfig.addSetting(Setting( self.name(), - Grass7Utils.GRASS_LOG_COMMANDS, + GrassUtils.GRASS_LOG_COMMANDS, self.tr('Log execution commands'), False)) ProcessingConfig.addSetting(Setting( self.name(), - Grass7Utils.GRASS_LOG_CONSOLE, + GrassUtils.GRASS_LOG_CONSOLE, self.tr('Log console output'), False)) ProcessingConfig.addSetting(Setting( self.name(), - Grass7Utils.GRASS_HELP_URL, + GrassUtils.GRASS_HELP_URL, self.tr('Location of GRASS docs'), '')) # Add settings for using r.external/v.external instead of r.in.gdal/v.in.ogr # but set them to False by default because the {r,v}.external implementations @@ -61,12 +61,12 @@ class Grass7AlgorithmProvider(QgsProcessingProvider): # For more info have a look at e.g. https://trac.osgeo.org/grass/ticket/3927 ProcessingConfig.addSetting(Setting( self.name(), - Grass7Utils.GRASS_USE_REXTERNAL, + GrassUtils.GRASS_USE_REXTERNAL, self.tr('For raster layers, use r.external (faster) instead of r.in.gdal'), False)) ProcessingConfig.addSetting(Setting( self.name(), - Grass7Utils.GRASS_USE_VEXTERNAL, + GrassUtils.GRASS_USE_VEXTERNAL, self.tr('For vector layers, use v.external (faster) instead of v.in.ogr'), False)) ProcessingConfig.readSettings() @@ -75,11 +75,11 @@ class Grass7AlgorithmProvider(QgsProcessingProvider): return True def unload(self): - ProcessingConfig.removeSetting(Grass7Utils.GRASS_LOG_COMMANDS) - ProcessingConfig.removeSetting(Grass7Utils.GRASS_LOG_CONSOLE) - ProcessingConfig.removeSetting(Grass7Utils.GRASS_HELP_URL) - ProcessingConfig.removeSetting(Grass7Utils.GRASS_USE_REXTERNAL) - ProcessingConfig.removeSetting(Grass7Utils.GRASS_USE_VEXTERNAL) + ProcessingConfig.removeSetting(GrassUtils.GRASS_LOG_COMMANDS) + ProcessingConfig.removeSetting(GrassUtils.GRASS_LOG_CONSOLE) + ProcessingConfig.removeSetting(GrassUtils.GRASS_HELP_URL) + ProcessingConfig.removeSetting(GrassUtils.GRASS_USE_REXTERNAL) + ProcessingConfig.removeSetting(GrassUtils.GRASS_USE_VEXTERNAL) def parse_algorithms(self) -> List[QgsProcessingAlgorithm]: """ @@ -87,7 +87,7 @@ class Grass7AlgorithmProvider(QgsProcessingProvider): algorithms. """ algs = [] - for folder in Grass7Utils.grassDescriptionFolders(): + for folder in GrassUtils.grassDescriptionFolders(): if (folder / 'algorithms.json').exists(): # fast approach -- use aggregated JSON summary of algorithms with open(folder / 'algorithms.json', 'rt', encoding='utf8') as f_in: @@ -96,7 +96,7 @@ class Grass7AlgorithmProvider(QgsProcessingProvider): algorithms_json = json.loads(algorithm_strings) for algorithm_json in algorithms_json: try: - alg = Grass7Algorithm( + alg = GrassAlgorithm( json_definition=algorithm_json, description_folder=folder) if alg.name().strip() != '': @@ -110,7 +110,7 @@ class Grass7AlgorithmProvider(QgsProcessingProvider): # slow approach - pass txt files one by one for descriptionFile in folder.glob('*.txt'): try: - alg = Grass7Algorithm( + alg = GrassAlgorithm( description_file=descriptionFile) if alg.name().strip() != '': algs.append(alg) @@ -122,7 +122,7 @@ class Grass7AlgorithmProvider(QgsProcessingProvider): return algs def loadAlgorithms(self): - version = Grass7Utils.installedVersion(True) + version = GrassUtils.installedVersion(True) if version is None: QgsMessageLog.logMessage(self.tr('Problem with GRASS installation: GRASS was not found or is not correctly installed'), self.tr('Processing'), Qgis.MessageLevel.Critical) @@ -135,7 +135,7 @@ class Grass7AlgorithmProvider(QgsProcessingProvider): return 'GRASS' def longName(self): - version = Grass7Utils.installedVersion() + version = GrassUtils.installedVersion() return 'GRASS GIS ({})'.format(version) if version is not None else "GRASS GIS" def id(self): @@ -173,10 +173,10 @@ class Grass7AlgorithmProvider(QgsProcessingProvider): return QgsVectorFileWriter.supportedFormatExtensions() def supportedOutputRasterLayerExtensions(self): - return Grass7Utils.getSupportedOutputRasterExtensions() + return GrassUtils.getSupportedOutputRasterExtensions() def canBeActivated(self): - return not bool(Grass7Utils.checkGrassIsInstalled()) + return not bool(GrassUtils.checkGrassIsInstalled()) def tr(self, string, context=''): if context == '': diff --git a/python/plugins/grassprovider/Grass7Utils.py b/python/plugins/grassprovider/grass_utils.py similarity index 86% rename from python/plugins/grassprovider/Grass7Utils.py rename to python/plugins/grassprovider/grass_utils.py index e2023e66ed8..99647e49a47 100644 --- a/python/plugins/grassprovider/Grass7Utils.py +++ b/python/plugins/grassprovider/grass_utils.py @@ -51,7 +51,7 @@ from processing.core.ProcessingConfig import ProcessingConfig from processing.tools.system import userFolder, isWindows, isMac, mkdir -class Grass7Utils: +class GrassUtils: GRASS_REGION_XMIN = 'GRASS7_REGION_XMIN' GRASS_REGION_YMIN = 'GRASS7_REGION_YMIN' GRASS_REGION_XMAX = 'GRASS7_REGION_XMAX' @@ -87,7 +87,7 @@ class Grass7Utils: On GNU/Linux and MacOSX it will be executed by a shell. On MS-Windows, it will be executed by cmd.exe. """ - gisdbase = Grass7Utils.grassDataFolder() + gisdbase = GrassUtils.grassDataFolder() if isWindows(): batchFile = os.path.join(gisdbase, 'grass_batch_job.cmd') else: @@ -112,10 +112,10 @@ class Grass7Utils: Returns the installed version of GRASS by launching the GRASS command with -v parameter. """ - if Grass7Utils.isGrassInstalled and not run: - return Grass7Utils.version + if GrassUtils.isGrassInstalled and not run: + return GrassUtils.version - if Grass7Utils.grassBin() is None: + if GrassUtils.grassBin() is None: return None # Launch GRASS command with -v parameter @@ -125,7 +125,7 @@ class Grass7Utils: si.dwFlags |= subprocess.STARTF_USESHOWWINDOW si.wShowWindow = subprocess.SW_HIDE with subprocess.Popen( - [Grass7Utils.command, '-v'], + [GrassUtils.command, '-v'], shell=False, stdout=subprocess.PIPE, stdin=subprocess.DEVNULL, @@ -139,8 +139,8 @@ class Grass7Utils: if "GRASS GIS " in line: line = line.split(" ")[-1].strip() if line.startswith("7.") or line.startswith("8."): - Grass7Utils.version = line - return Grass7Utils.version + GrassUtils.version = line + return GrassUtils.version except Exception: pass @@ -165,10 +165,10 @@ class Grass7Utils: return os.path.join(root, cmd) return None - if Grass7Utils.command: - return Grass7Utils.command + if GrassUtils.command: + return GrassUtils.command - path = Grass7Utils.grassPath() + path = GrassUtils.grassPath() command = None vn = os.path.join(path, "etc", "VERSIONNUMBER") @@ -213,9 +213,9 @@ class Grass7Utils: break if command: - Grass7Utils.command = command + GrassUtils.command = command if path == '': - Grass7Utils.path = os.path.dirname(command) + GrassUtils.path = os.path.dirname(command) return command @@ -225,8 +225,8 @@ class Grass7Utils: Find GRASS path on the operating system. Sets global variable Grass7Utils.path """ - if Grass7Utils.path is not None: - return Grass7Utils.path + if GrassUtils.path is not None: + return GrassUtils.path if not isWindows() and not isMac(): return '' @@ -273,7 +273,7 @@ class Grass7Utils: break if folder is not None: - Grass7Utils.path = folder + GrassUtils.path = folder return folder or '' @@ -294,7 +294,7 @@ class Grass7Utils: Note that the provider will load from these in sequence, so we put the userDescriptionFolder first to allow users to create modified versions of stock algorithms shipped with QGIS. """ - return [Grass7Utils.userDescriptionFolder(), + return [GrassUtils.userDescriptionFolder(), Path(__file__).parent.joinpath('description')] @staticmethod @@ -308,14 +308,14 @@ class Grass7Utils: @staticmethod def createGrassBatchJobFileFromGrassCommands(commands): - with open(Grass7Utils.grassBatchJobFilename(), 'w') as fout: + with open(GrassUtils.grassBatchJobFilename(), 'w') as fout: if not isWindows(): fout.write('#!/bin/sh\n') else: fout.write( - 'chcp {}>NUL\n'.format(Grass7Utils.getWindowsCodePage())) + 'chcp {}>NUL\n'.format(GrassUtils.getWindowsCodePage())) for command in commands: - Grass7Utils.writeCommand(fout, command) + GrassUtils.writeCommand(fout, command) fout.write('exit') @staticmethod @@ -323,7 +323,7 @@ class Grass7Utils: """ Creates and returns the GRASS temporary DB LOCATION directory. """ - folder = os.path.join(Grass7Utils.grassDataFolder(), 'temp_location') + folder = os.path.join(GrassUtils.grassDataFolder(), 'temp_location') mkdir(folder) return folder @@ -347,16 +347,16 @@ class Grass7Utils: projection will be set later, based on the projection of the first input image or vector """ - folder = Grass7Utils.grassMapsetFolder() + folder = GrassUtils.grassMapsetFolder() mkdir(os.path.join(folder, 'PERMANENT')) mkdir(os.path.join(folder, 'PERMANENT', '.tmp')) - Grass7Utils.writeGrassWindow( + GrassUtils.writeGrassWindow( os.path.join(folder, 'PERMANENT', 'DEFAULT_WIND')) with open(os.path.join(folder, 'PERMANENT', 'MYNAME'), 'w') as outfile: outfile.write( 'QGIS GRASS GIS 7 interface: temporary data processing location.\n') - Grass7Utils.writeGrassWindow(os.path.join(folder, 'PERMANENT', 'WIND')) + GrassUtils.writeGrassWindow(os.path.join(folder, 'PERMANENT', 'WIND')) mkdir(os.path.join(folder, 'PERMANENT', 'sqlite')) with open(os.path.join(folder, 'PERMANENT', 'VAR'), 'w') as outfile: outfile.write('DB_DRIVER: sqlite\n') @@ -394,27 +394,27 @@ class Grass7Utils: Prepare GRASS batch job in a script and returns it as a command ready for subprocess. """ - if Grass7Utils.command is None: - Grass7Utils.grassBin() + if GrassUtils.command is None: + GrassUtils.grassBin() env = os.environ.copy() env['GRASS_MESSAGE_FORMAT'] = 'plain' if 'GISBASE' in env: del env['GISBASE'] - Grass7Utils.createGrassBatchJobFileFromGrassCommands(commands) - os.chmod(Grass7Utils.grassBatchJobFilename(), + GrassUtils.createGrassBatchJobFileFromGrassCommands(commands) + os.chmod(GrassUtils.grassBatchJobFilename(), stat.S_IEXEC | stat.S_IREAD | stat.S_IWRITE) - command = [Grass7Utils.command, - os.path.join(Grass7Utils.grassMapsetFolder(), 'PERMANENT'), - '--exec', Grass7Utils.grassBatchJobFilename()] + command = [GrassUtils.command, + os.path.join(GrassUtils.grassMapsetFolder(), 'PERMANENT'), + '--exec', GrassUtils.grassBatchJobFilename()] return command, env @staticmethod def executeGrass(commands, feedback, outputCommands=None): - loglines = [Grass7Utils.tr('GRASS GIS 7 execution console output')] + loglines = [GrassUtils.tr('GRASS GIS 7 execution console output')] grassOutDone = False - command, grassenv = Grass7Utils.prepareGrassExecution(commands) + command, grassenv = GrassUtils.prepareGrassExecution(commands) # QgsMessageLog.logMessage('exec: {}'.format(command), 'DEBUG', Qgis.Info) # For MS-Windows, we need to hide the console window. @@ -426,7 +426,7 @@ class Grass7Utils: kw['startupinfo'] = si if sys.version_info >= (3, 6): kw['encoding'] = "cp{}".format( - Grass7Utils.getWindowsCodePage()) + GrassUtils.getWindowsCodePage()) def readline_with_recover(stdout): """A method wrapping stdout.readline() with try-except recovering. @@ -467,15 +467,15 @@ class Grass7Utils: feedback.reportError(line.strip()) elif 'Segmentation fault' in line: feedback.reportError(line.strip()) - feedback.reportError('\n' + Grass7Utils.tr( + feedback.reportError('\n' + GrassUtils.tr( 'GRASS command crashed :( Try a different set of input parameters and consult the GRASS algorithm manual for more information.') + '\n') if ProcessingConfig.getSetting( - Grass7Utils.GRASS_USE_REXTERNAL): - feedback.reportError(Grass7Utils.tr( + GrassUtils.GRASS_USE_REXTERNAL): + feedback.reportError(GrassUtils.tr( 'Suggest disabling the experimental "use r.external" option from the Processing GRASS Provider options.') + '\n') if ProcessingConfig.getSetting( - Grass7Utils.GRASS_USE_VEXTERNAL): - feedback.reportError(Grass7Utils.tr( + GrassUtils.GRASS_USE_VEXTERNAL): + feedback.reportError(GrassUtils.tr( 'Suggest disabling the experimental "use v.external" option from the Processing GRASS Provider options.') + '\n') elif line.strip(): feedback.pushConsoleInfo(line.strip()) @@ -486,7 +486,7 @@ class Grass7Utils: # are usually the output ones. If that is the case runs the output # commands again. if not grassOutDone and outputCommands: - command, grassenv = Grass7Utils.prepareGrassExecution( + command, grassenv = GrassUtils.prepareGrassExecution( outputCommands) # For MS-Windows, we need to hide the console window. kw = {} @@ -497,7 +497,7 @@ class Grass7Utils: kw['startupinfo'] = si if sys.version_info >= (3, 6): kw['encoding'] = "cp{}".format( - Grass7Utils.getWindowsCodePage()) + GrassUtils.getWindowsCodePage()) with subprocess.Popen( command, shell=False, @@ -523,7 +523,7 @@ class Grass7Utils: loglines.append(line.strip()) feedback.pushConsoleInfo(line.strip()) - if ProcessingConfig.getSetting(Grass7Utils.GRASS_LOG_CONSOLE): + if ProcessingConfig.getSetting(GrassUtils.GRASS_LOG_CONSOLE): QgsMessageLog.logMessage('\n'.join(loglines), 'Processing', Qgis.MessageLevel.Info) @@ -535,67 +535,67 @@ class Grass7Utils: # structure @staticmethod def startGrassSession(): - if not Grass7Utils.sessionRunning: - Grass7Utils.createTempMapset() - Grass7Utils.sessionRunning = True + if not GrassUtils.sessionRunning: + GrassUtils.createTempMapset() + GrassUtils.sessionRunning = True # End session by removing the temporary GRASS mapset and all # the layers. @staticmethod def endGrassSession(): # shutil.rmtree(Grass7Utils.grassMapsetFolder(), True) - Grass7Utils.sessionRunning = False - Grass7Utils.sessionLayers = {} - Grass7Utils.projectionSet = False + GrassUtils.sessionRunning = False + GrassUtils.sessionLayers = {} + GrassUtils.projectionSet = False @staticmethod def getSessionLayers(): - return Grass7Utils.sessionLayers + return GrassUtils.sessionLayers @staticmethod def addSessionLayers(exportedLayers): - Grass7Utils.sessionLayers = dict( - list(Grass7Utils.sessionLayers.items()) + + GrassUtils.sessionLayers = dict( + list(GrassUtils.sessionLayers.items()) + list(exportedLayers.items())) @staticmethod def checkGrassIsInstalled(ignorePreviousState=False): if not ignorePreviousState: - if Grass7Utils.isGrassInstalled: + if GrassUtils.isGrassInstalled: return # We check the version of Grass7 - if Grass7Utils.installedVersion() is not None: + if GrassUtils.installedVersion() is not None: # For Ms-Windows, we check GRASS binaries if isWindows(): - cmdpath = os.path.join(Grass7Utils.path, 'bin', + cmdpath = os.path.join(GrassUtils.path, 'bin', 'r.out.gdal.exe') if not os.path.exists(cmdpath): - return Grass7Utils.tr( + return GrassUtils.tr( 'The GRASS GIS folder "{}" does not contain a valid set ' 'of GRASS modules.\nPlease, check that GRASS is correctly ' 'installed and available on your system.'.format( - os.path.join(Grass7Utils.path, 'bin'))) - Grass7Utils.isGrassInstalled = True + os.path.join(GrassUtils.path, 'bin'))) + GrassUtils.isGrassInstalled = True return # Return error messages else: # MS-Windows or MacOSX if isWindows() or isMac(): - if Grass7Utils.path is None: - return Grass7Utils.tr( + if GrassUtils.path is None: + return GrassUtils.tr( 'Could not locate GRASS GIS folder. Please make ' 'sure that GRASS GIS is correctly installed before ' 'running GRASS algorithms.') - if Grass7Utils.command is None: - return Grass7Utils.tr( + if GrassUtils.command is None: + return GrassUtils.tr( 'GRASS GIS 7 binary {} can\'t be found on this system from a shell. ' 'Please install it or configure your PATH {} environment variable.'.format( '(grass.bat)' if isWindows() else '(grass.sh)', 'or OSGEO4W_ROOT' if isWindows() else '')) # GNU/Linux else: - return Grass7Utils.tr( + return GrassUtils.tr( 'GRASS 7 can\'t be found on this system from a shell. ' 'Please install it or configure your PATH environment variable.') @@ -616,12 +616,12 @@ class Grass7Utils: @staticmethod def grassHelpPath(): - helpPath = ProcessingConfig.getSetting(Grass7Utils.GRASS_HELP_URL) + helpPath = ProcessingConfig.getSetting(GrassUtils.GRASS_HELP_URL) if not helpPath: if isWindows() or isMac(): - if Grass7Utils.path is not None: - localPath = os.path.join(Grass7Utils.path, 'docs/html') + if GrassUtils.path is not None: + localPath = os.path.join(GrassUtils.path, 'docs/html') if os.path.exists(localPath): helpPath = os.path.abspath(localPath) else: @@ -635,8 +635,8 @@ class Grass7Utils: if helpPath: return helpPath - elif Grass7Utils.version: - version = Grass7Utils.version.replace('.', '')[:2] + elif GrassUtils.version: + version = GrassUtils.version.replace('.', '')[:2] return 'https://grass.osgeo.org/grass{}/manuals/'.format(version) else: # GRASS not available! diff --git a/python/plugins/grassprovider/tests/CMakeLists.txt b/python/plugins/grassprovider/tests/CMakeLists.txt index b2e05d22272..22fff5c654a 100644 --- a/python/plugins/grassprovider/tests/CMakeLists.txt +++ b/python/plugins/grassprovider/tests/CMakeLists.txt @@ -4,8 +4,8 @@ PLUGIN_INSTALL(grassprovider tests ${PY_FILES}) if(ENABLE_TESTS) include(UsePythonTest) - ADD_PYTHON_TEST(ProcessingGrass7AlgorithmsImageryTest Grass7AlgorithmsImageryTest.py) - ADD_PYTHON_TEST(ProcessingGrass7AlgorithmsRasterTestPt1 Grass7AlgorithmsRasterTestPt1.py) - ADD_PYTHON_TEST(ProcessingGrass7AlgorithmsRasterTestPt2 Grass7AlgorithmsRasterTestPt2.py) - ADD_PYTHON_TEST(ProcessingGrass7AlgorithmsVectorTest Grass7AlgorithmsVectorTest.py) + ADD_PYTHON_TEST(ProcessingGrassAlgorithmsImageryTest grass_algorithms_imagery_test.py) + ADD_PYTHON_TEST(ProcessingGrassAlgorithmsRasterTestPt1 grass_algorithms_raster_test_pt1.py) + ADD_PYTHON_TEST(ProcessingGrassAlgorithmsRasterTestPt2 grass_algorithms_raster_test_pt2.py) + ADD_PYTHON_TEST(ProcessingGrassAlgorithmsVectorTest grass_algorithms_vector_test.py) endif() diff --git a/python/plugins/grassprovider/tests/Grass7AlgorithmsImageryTest.py b/python/plugins/grassprovider/tests/grass_algorithms_imagery_test.py similarity index 87% rename from python/plugins/grassprovider/tests/Grass7AlgorithmsImageryTest.py rename to python/plugins/grassprovider/tests/grass_algorithms_imagery_test.py index aa5f40bfac3..2f6dc37e1c6 100644 --- a/python/plugins/grassprovider/tests/Grass7AlgorithmsImageryTest.py +++ b/python/plugins/grassprovider/tests/grass_algorithms_imagery_test.py @@ -1,6 +1,6 @@ """ *************************************************************************** - Grass7AlgorithmsImageryTest.py + grass_algorithms_imagery_test.py ------------------------------ Date : May 2016 Copyright : (C) 2016 by Médéric Ribreux @@ -29,8 +29,8 @@ from qgis.testing import ( QgisTestCase, start_app ) -from grassprovider.Grass7AlgorithmProvider import Grass7AlgorithmProvider -from grassprovider.Grass7Utils import Grass7Utils +from grassprovider.grass_provider import GrassProvider +from grassprovider.grass_utils import GrassUtils class TestGrass7AlgorithmsImageryTest(QgisTestCase, AlgorithmsTestBase.AlgorithmsTest): @@ -38,11 +38,11 @@ class TestGrass7AlgorithmsImageryTest(QgisTestCase, AlgorithmsTestBase.Algorithm @classmethod def setUpClass(cls): start_app() - cls.provider = Grass7AlgorithmProvider() + cls.provider = GrassProvider() QgsApplication.processingRegistry().addProvider(cls.provider) cls.cleanup_paths = [] - assert Grass7Utils.installedVersion() + assert GrassUtils.installedVersion() @classmethod def tearDownClass(cls): diff --git a/python/plugins/grassprovider/tests/Grass7AlgorithmsRasterTestPt1.py b/python/plugins/grassprovider/tests/grass_algorithms_raster_test_pt1.py similarity index 87% rename from python/plugins/grassprovider/tests/Grass7AlgorithmsRasterTestPt1.py rename to python/plugins/grassprovider/tests/grass_algorithms_raster_test_pt1.py index 8a93a312b43..e7b1aa00312 100644 --- a/python/plugins/grassprovider/tests/Grass7AlgorithmsRasterTestPt1.py +++ b/python/plugins/grassprovider/tests/grass_algorithms_raster_test_pt1.py @@ -1,6 +1,6 @@ """ *************************************************************************** - Grass7AlgorithmsRasterTestPt1.py + grass_algorithms_raster_test_pt1.py ----------------------------- Date : May 2016 Copyright : (C) 2016 by Médéric Ribreux @@ -30,8 +30,8 @@ from qgis.testing import ( start_app ) -from grassprovider.Grass7AlgorithmProvider import Grass7AlgorithmProvider -from grassprovider.Grass7Utils import Grass7Utils +from grassprovider.grass_provider import GrassProvider +from grassprovider.grass_utils import GrassUtils class TestGrass7AlgorithmsRasterTest(QgisTestCase, AlgorithmsTestBase.AlgorithmsTest): @@ -39,11 +39,11 @@ class TestGrass7AlgorithmsRasterTest(QgisTestCase, AlgorithmsTestBase.Algorithms @classmethod def setUpClass(cls): start_app() - cls.provider = Grass7AlgorithmProvider() + cls.provider = GrassProvider() QgsApplication.processingRegistry().addProvider(cls.provider) cls.cleanup_paths = [] - assert Grass7Utils.installedVersion() + assert GrassUtils.installedVersion() @classmethod def tearDownClass(cls): diff --git a/python/plugins/grassprovider/tests/Grass7AlgorithmsRasterTestPt2.py b/python/plugins/grassprovider/tests/grass_algorithms_raster_test_pt2.py similarity index 92% rename from python/plugins/grassprovider/tests/Grass7AlgorithmsRasterTestPt2.py rename to python/plugins/grassprovider/tests/grass_algorithms_raster_test_pt2.py index ee7f7153187..e9ddee6d026 100644 --- a/python/plugins/grassprovider/tests/Grass7AlgorithmsRasterTestPt2.py +++ b/python/plugins/grassprovider/tests/grass_algorithms_raster_test_pt2.py @@ -1,6 +1,6 @@ """ *************************************************************************** - Grass7AlgorithmsRasterTestPt2.py + grass_algorithms_raster_test_pt2.py ----------------------------- Date : May 2016 Copyright : (C) 2016 by Médéric Ribreux @@ -35,8 +35,8 @@ from qgis.testing import ( QgisTestCase, start_app ) -from grassprovider.Grass7AlgorithmProvider import Grass7AlgorithmProvider -from grassprovider.Grass7Utils import Grass7Utils +from grassprovider.grass_provider import GrassProvider +from grassprovider.grass_utils import GrassUtils testDataPath = os.path.join(os.path.dirname(__file__), 'testdata') @@ -47,14 +47,14 @@ class TestGrass7AlgorithmsRasterTest(QgisTestCase, AlgorithmsTestBase.Algorithms @classmethod def setUpClass(cls): start_app() - cls.provider = Grass7AlgorithmProvider() + cls.provider = GrassProvider() QgsApplication.processingRegistry().addProvider(cls.provider) cls.cleanup_paths = [] cls.temp_dir = tempfile.mkdtemp() cls.cleanup_paths.append(cls.temp_dir) - assert Grass7Utils.installedVersion() + assert GrassUtils.installedVersion() @classmethod def tearDownClass(cls): diff --git a/python/plugins/grassprovider/tests/Grass7AlgorithmsVectorTest.py b/python/plugins/grassprovider/tests/grass_algorithms_vector_test.py similarity index 98% rename from python/plugins/grassprovider/tests/Grass7AlgorithmsVectorTest.py rename to python/plugins/grassprovider/tests/grass_algorithms_vector_test.py index d73f664a5c5..c42de15257d 100644 --- a/python/plugins/grassprovider/tests/Grass7AlgorithmsVectorTest.py +++ b/python/plugins/grassprovider/tests/grass_algorithms_vector_test.py @@ -1,6 +1,6 @@ """ *************************************************************************** - Grass7AlgorithmsVectorTest.py + grass_algorithms_vector_test.py ----------------------------- Date : April 2018 Copyright : (C) 2018 by Nyall Dawson @@ -40,8 +40,8 @@ from qgis.testing import ( QgisTestCase, start_app ) -from grassprovider.Grass7AlgorithmProvider import Grass7AlgorithmProvider -from grassprovider.Grass7Utils import Grass7Utils +from grassprovider.grass_provider import GrassProvider +from grassprovider.grass_utils import GrassUtils testDataPath = os.path.join(os.path.dirname(__file__), 'testdata') @@ -52,14 +52,14 @@ class TestGrass7AlgorithmsVectorTest(QgisTestCase, AlgorithmsTestBase.Algorithms @classmethod def setUpClass(cls): start_app() - cls.provider = Grass7AlgorithmProvider() + cls.provider = GrassProvider() QgsApplication.processingRegistry().addProvider(cls.provider) cls.cleanup_paths = [] cls.temp_dir = tempfile.mkdtemp() cls.cleanup_paths.append(cls.temp_dir) - assert Grass7Utils.installedVersion() + assert GrassUtils.installedVersion() @classmethod def tearDownClass(cls): diff --git a/python/plugins/grassprovider/tests/grass7_todo.md b/python/plugins/grassprovider/tests/grass_todo.md similarity index 100% rename from python/plugins/grassprovider/tests/grass7_todo.md rename to python/plugins/grassprovider/tests/grass_todo.md diff --git a/python/plugins/processing/core/Processing.py b/python/plugins/processing/core/Processing.py index 6b249ba3292..e178cfa7cec 100644 --- a/python/plugins/processing/core/Processing.py +++ b/python/plugins/processing/core/Processing.py @@ -122,8 +122,8 @@ class Processing: if QgsApplication.platform() == 'external': # for external applications we must also load the builtin providers stored in separate plugins try: - from grassprovider.Grass7AlgorithmProvider import Grass7AlgorithmProvider - p = Grass7AlgorithmProvider() + from grassprovider.grass_provider import GrassProvider + p = GrassProvider() if QgsApplication.processingRegistry().addProvider(p): Processing.BASIC_PROVIDERS.append(p) except ImportError: