mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-22 00:06:12 -05:00
Rename more references to grass7 to version-less "grass"
This commit is contained in:
parent
0ab66b7b6f
commit
ea3a86508e
@ -138,9 +138,9 @@ ProcessingGdalAlgorithmsGeneralTest
|
|||||||
ProcessingGdalAlgorithmsRasterTest
|
ProcessingGdalAlgorithmsRasterTest
|
||||||
ProcessingGdalAlgorithmsVectorTest
|
ProcessingGdalAlgorithmsVectorTest
|
||||||
ProcessingCheckValidityAlgorithmTest
|
ProcessingCheckValidityAlgorithmTest
|
||||||
ProcessingGrass7AlgorithmsImageryTest
|
ProcessingGrassAlgorithmsImageryTest
|
||||||
ProcessingGrass7AlgorithmsRasterTestPt1
|
ProcessingGrassAlgorithmsRasterTestPt1
|
||||||
ProcessingGrass7AlgorithmsRasterTestPt2
|
ProcessingGrassAlgorithmsRasterTestPt2
|
||||||
ProcessingGrass7AlgorithmsVectorTest
|
ProcessingGrassAlgorithmsVectorTest
|
||||||
PyQgsCoordinateReferenceSystemModel
|
PyQgsCoordinateReferenceSystemModel
|
||||||
PyQgsProviderRegistry
|
PyQgsProviderRegistry
|
||||||
|
@ -103,7 +103,7 @@ def regroupRasters(alg, parameters, context, src, group, subgroup=None, extFile=
|
|||||||
# extFileName = new_parameters[ext]
|
# extFileName = new_parameters[ext]
|
||||||
# if extFileName:
|
# if extFileName:
|
||||||
# shortFileName = os.path.basename(extFileName)
|
# shortFileName = os.path.basename(extFileName)
|
||||||
# destPath = os.path.join(Grass7Utils.grassMapsetFolder(),
|
# destPath = os.path.join(GrassUtils.grassMapsetFolder(),
|
||||||
# 'PERMANENT',
|
# 'PERMANENT',
|
||||||
# 'group', new_parameters[group.name()],
|
# 'group', new_parameters[group.name()],
|
||||||
# 'subgroup', new_parameters[subgroup.name()],
|
# 'subgroup', new_parameters[subgroup.name()],
|
||||||
@ -184,7 +184,7 @@ def verifyRasterNum(alg, parameters, context, rasters, mini, maxi=None):
|
|||||||
|
|
||||||
|
|
||||||
def createDestDir(alg, toFile):
|
def createDestDir(alg, toFile):
|
||||||
""" Generates an mkdir command for GRASS7 script """
|
""" Generates an mkdir command for GRASS script """
|
||||||
# Creates the destination directory
|
# Creates the destination directory
|
||||||
command = "{} \"{}\"".format(
|
command = "{} \"{}\"".format(
|
||||||
"MD" if isWindows() else "mkdir -p",
|
"MD" if isWindows() else "mkdir -p",
|
||||||
@ -194,7 +194,7 @@ def createDestDir(alg, toFile):
|
|||||||
|
|
||||||
|
|
||||||
def moveFile(alg, fromFile, toFile):
|
def moveFile(alg, fromFile, toFile):
|
||||||
""" Generates a move command for GRASS7 script """
|
""" Generates a move command for GRASS script """
|
||||||
createDestDir(alg, toFile)
|
createDestDir(alg, toFile)
|
||||||
command = "{} \"{}\" \"{}\"".format(
|
command = "{} \"{}\" \"{}\"".format(
|
||||||
"MOVE /Y" if isWindows() else "mv -f",
|
"MOVE /Y" if isWindows() else "mv -f",
|
||||||
@ -205,7 +205,7 @@ def moveFile(alg, fromFile, toFile):
|
|||||||
|
|
||||||
|
|
||||||
def copyFile(alg, fromFile, toFile):
|
def copyFile(alg, fromFile, toFile):
|
||||||
""" Generates a copy command for GRASS7 script """
|
""" Generates a copy command for GRASS script """
|
||||||
createDestDir(alg, toFile)
|
createDestDir(alg, toFile)
|
||||||
command = "{} \"{}\" \"{}\"".format(
|
command = "{} \"{}\" \"{}\"".format(
|
||||||
"COPY /Y" if isWindows() else "cp -f",
|
"COPY /Y" if isWindows() else "cp -f",
|
||||||
|
@ -31,7 +31,7 @@ if os.name == 'nt':
|
|||||||
|
|
||||||
|
|
||||||
def rliPath():
|
def rliPath():
|
||||||
"""Return r.li GRASS7 user dir"""
|
"""Return r.li GRASS user dir"""
|
||||||
if isWindows():
|
if isWindows():
|
||||||
homeDir = win32api.GetShortPathName(os.path.expanduser('~'))
|
homeDir = win32api.GetShortPathName(os.path.expanduser('~'))
|
||||||
return os.path.join(homeDir, 'AppData', 'Roaming', 'GRASS7', 'r.li')
|
return os.path.join(homeDir, 'AppData', 'Roaming', 'GRASS7', 'r.li')
|
||||||
@ -82,17 +82,17 @@ def configFile(alg, parameters, context, feedback, outputTxt=False):
|
|||||||
"""Handle inline configuration
|
"""Handle inline configuration
|
||||||
:param parameters:
|
:param parameters:
|
||||||
"""
|
"""
|
||||||
# Where is the GRASS7 user directory ?
|
# Where is the GRASS user directory ?
|
||||||
userGrass7Path = rliPath()
|
user_grass_path = rliPath()
|
||||||
if not os.path.isdir(userGrass7Path):
|
if not os.path.isdir(user_grass_path):
|
||||||
mkdir(userGrass7Path)
|
mkdir(user_grass_path)
|
||||||
if not os.path.isdir(os.path.join(userGrass7Path, 'output')):
|
if not os.path.isdir(os.path.join(user_grass_path, 'output')):
|
||||||
mkdir(os.path.join(userGrass7Path, 'output'))
|
mkdir(os.path.join(user_grass_path, 'output'))
|
||||||
|
|
||||||
# If we have a configuration file, we need to copy it into user dir
|
# If we have a configuration file, we need to copy it into user dir
|
||||||
if parameters['config']:
|
if parameters['config']:
|
||||||
fileName = alg.parameterAsString(parameters, 'config', context)
|
fileName = alg.parameterAsString(parameters, 'config', context)
|
||||||
configFilePath = os.path.join(userGrass7Path, os.path.basename(fileName))
|
configFilePath = os.path.join(user_grass_path, os.path.basename(fileName))
|
||||||
# Copy the file
|
# Copy the file
|
||||||
shutil.copy(parameters['config'], configFilePath)
|
shutil.copy(parameters['config'], configFilePath)
|
||||||
# Change the parameter value
|
# Change the parameter value
|
||||||
@ -101,7 +101,7 @@ def configFile(alg, parameters, context, feedback, outputTxt=False):
|
|||||||
elif parameters['config_txt']:
|
elif parameters['config_txt']:
|
||||||
# Creates a temporary txt file in user r.li directory
|
# Creates a temporary txt file in user r.li directory
|
||||||
tempConfig = os.path.basename(getTempFilename(context=context))
|
tempConfig = os.path.basename(getTempFilename(context=context))
|
||||||
configFilePath = os.path.join(userGrass7Path, tempConfig)
|
configFilePath = os.path.join(user_grass_path, tempConfig)
|
||||||
# Inject rules into temporary txt file
|
# Inject rules into temporary txt file
|
||||||
with open(configFilePath, "w") as f:
|
with open(configFilePath, "w") as f:
|
||||||
f.write(alg.parameterAsString(parameters, 'config_txt', context))
|
f.write(alg.parameterAsString(parameters, 'config_txt', context))
|
||||||
@ -128,9 +128,9 @@ def configFile(alg, parameters, context, feedback, outputTxt=False):
|
|||||||
def moveOutputTxtFile(alg, parameters, context):
|
def moveOutputTxtFile(alg, parameters, context):
|
||||||
# Find output file name:
|
# Find output file name:
|
||||||
txtPath = alg.parameterAsString(parameters, 'output_txt', context)
|
txtPath = alg.parameterAsString(parameters, 'output_txt', context)
|
||||||
userGrass7Path = rliPath()
|
user_grass_path = rliPath()
|
||||||
|
|
||||||
output = os.path.join(userGrass7Path, 'output',
|
output = os.path.join(user_grass_path, 'output',
|
||||||
alg.parameterAsString(parameters, 'output', context))
|
alg.parameterAsString(parameters, 'output', context))
|
||||||
# move the file
|
# move the file
|
||||||
if isWindows():
|
if isWindows():
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
* *
|
* *
|
||||||
***************************************************************************
|
***************************************************************************
|
||||||
|
|
||||||
This Python module handles pre-treatment operations for v.net.* GRASS7 modules.
|
This Python module handles pre-treatment operations for v.net.* GRASS modules.
|
||||||
Before using a v.net module you often have to incorporate a points layer into
|
Before using a v.net module you often have to incorporate a points layer into
|
||||||
the network vector map.
|
the network vector map.
|
||||||
"""
|
"""
|
||||||
|
@ -2,8 +2,8 @@ A short guide for creating and editing GRASS GIS processing algorithms:
|
|||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
|
|
||||||
For a GRASS command to be executed within QGIS a plain text description file is needed
|
For a GRASS command to be executed within QGIS a plain text description file is needed
|
||||||
to define the inputs required by the command, the output it generates and the parameters
|
to define the inputs required by the command, the output it generates and the parameters
|
||||||
that are used to configure it. Each command is described in a separate text file, but some
|
that are used to configure it. Each command is described in a separate text file, but some
|
||||||
commands can be split into several algorithms by using more than one description file,
|
commands can be split into several algorithms by using more than one description file,
|
||||||
so that more than one entry is shown in the algorithms list. Splitting a grass command
|
so that more than one entry is shown in the algorithms list. Splitting a grass command
|
||||||
was originally done because the processing provider did not support optional parameters,
|
was originally done because the processing provider did not support optional parameters,
|
||||||
@ -15,7 +15,7 @@ create new algorithms or improve existing algorithms.
|
|||||||
Each file starts with three lines containing:
|
Each file starts with three lines containing:
|
||||||
|
|
||||||
- The name of the grass command to call to execute the algorithm (e.g. v.buffer)
|
- The name of the grass command to call to execute the algorithm (e.g. v.buffer)
|
||||||
- The description of the algorithm to show to the user. For split commands you must
|
- The description of the algorithm to show to the user. For split commands you must
|
||||||
include the algorithm id first, e.g.:
|
include the algorithm id first, e.g.:
|
||||||
r.sun.insoltime - Solar irradiance and irradiation model (daily sums).
|
r.sun.insoltime - Solar irradiance and irradiation model (daily sums).
|
||||||
and
|
and
|
||||||
@ -155,7 +155,7 @@ Example: *QgsProcessingParameterBoolean|-i|Output raster map as integer|False
|
|||||||
|
|
||||||
RELOADING ALGORITHM DESCRIPTIONS
|
RELOADING ALGORITHM DESCRIPTIONS
|
||||||
---------------------------------------
|
---------------------------------------
|
||||||
You do not need to restart QGIS after editing or creating an algorithm description - simply click the wrench icon in the processing toolbox, then click OK, and QGIS will reload the descriptions.
|
You do not need to restart QGIS after editing or creating an algorithm description - simply click the wrench icon in the processing toolbox, then click OK, and QGIS will reload the descriptions.
|
||||||
|
|
||||||
ADVANCED PROCESSING
|
ADVANCED PROCESSING
|
||||||
--------------------------
|
--------------------------
|
||||||
@ -165,13 +165,13 @@ To save the console output from GRASS to file, simply create a QgsProcessingPara
|
|||||||
Example: QgsProcessingParameterFileDestination|html|List of addons|Html files (*.html)|addons_list.html|False
|
Example: QgsProcessingParameterFileDestination|html|List of addons|Html files (*.html)|addons_list.html|False
|
||||||
|
|
||||||
To add additional logic to an algorithm, like a preliminary check on data, the use of more than one GRASS command,
|
To add additional logic to an algorithm, like a preliminary check on data, the use of more than one GRASS command,
|
||||||
or a transformation of output data, then you need to use the ext mechanism.
|
or a transformation of output data, then you need to use the ext mechanism.
|
||||||
|
|
||||||
There are 4 different levels where you can add logic:
|
There are 4 different levels where you can add logic:
|
||||||
- Checking the input parameters, e.g. if you want to verify that two mutually exclusive options have not been both enabled.
|
- Checking the input parameters, e.g. if you want to verify that two mutually exclusive options have not been both enabled.
|
||||||
- Processing inputs import: if you need to do more than importing input layers.
|
- Processing inputs import: if you need to do more than importing input layers.
|
||||||
- Processing the command itself: if you need to chain more than one GRASS command for your algorithm.
|
- Processing the command itself: if you need to chain more than one GRASS command for your algorithm.
|
||||||
- Processing the outputs: if you need to do special things before exporting layers or if you need special export methods.
|
- Processing the outputs: if you need to do special things before exporting layers or if you need special export methods.
|
||||||
|
|
||||||
To add some logic on one (or more) level(s), you have to create a .py file named according to the algorithm name in python/plugins/grassprovider/ext, replacing '.' with '_'.
|
To add some logic on one (or more) level(s), you have to create a .py file named according to the algorithm name in python/plugins/grassprovider/ext, replacing '.' with '_'.
|
||||||
Then you need to create methods using the respective names:
|
Then you need to create methods using the respective names:
|
||||||
@ -180,10 +180,10 @@ Then you need to create methods using the respective names:
|
|||||||
- Command: processCommand
|
- Command: processCommand
|
||||||
- Outputs: processOutputs
|
- Outputs: processOutputs
|
||||||
|
|
||||||
If there is a Python file with the algorithm name in the ext directory, methods will be imported from the file and run instead of the common methods (there are "standard" processCommand/processInputs/processOutputs/checkParameterValuesBeforeExecuting methods in the code of the GRASS provider for QGIS Processing, in python/plugins/grassprovider/Grass7Algorithm.py).
|
If there is a Python file with the algorithm name in the ext directory, methods will be imported from the file and run instead of the common methods (there are "standard" processCommand/processInputs/processOutputs/checkParameterValuesBeforeExecuting methods in the code of the GRASS provider for QGIS Processing, in python/plugins/grassprovider/grass_algorithm.py).
|
||||||
|
|
||||||
If we take the example of v.what.rast, there is an ext file: ext/v_what_rast.py.
|
If we take the example of v.what.rast, there is an ext file: ext/v_what_rast.py.
|
||||||
In this file there is a processCommand method. It just launches the standard processCommand but with the delOutputs option set to True (we do not want to have standard outputs).
|
In this file there is a processCommand method. It just launches the standard processCommand but with the delOutputs option set to True (we do not want to have standard outputs).
|
||||||
Then there is also a customized processOutputs which exports the input vector as an output for QGIS. We need to do this because v.what.rast modifies values directly in the input vector layer instead of generating a new output, so we have to build this output ourself.
|
Then there is also a customized processOutputs which exports the input vector as an output for QGIS. We need to do this because v.what.rast modifies values directly in the input vector layer instead of generating a new output, so we have to build this output ourself.
|
||||||
|
|
||||||
If you want to do special things in the ext mechanism, you will need to read (and understand) the GRASS provider code standard methods in Grass7Algorithm.py.
|
If you want to do special things in the ext mechanism, you will need to read (and understand) the GRASS provider code standard methods in Grass7Algorithm.py.
|
||||||
|
@ -117,7 +117,7 @@ class GrassAlgorithm(QgsProcessingAlgorithm):
|
|||||||
self._short_description = ''
|
self._short_description = ''
|
||||||
self._group = ''
|
self._group = ''
|
||||||
self._groupId = ''
|
self._groupId = ''
|
||||||
self.grass7Name = ''
|
self.grass_name = ''
|
||||||
self.params = []
|
self.params = []
|
||||||
self.hardcodedStrings = []
|
self.hardcodedStrings = []
|
||||||
self.inputLayers = []
|
self.inputLayers = []
|
||||||
@ -216,9 +216,9 @@ class GrassAlgorithm(QgsProcessingAlgorithm):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
if os.path.exists(helpPath):
|
if os.path.exists(helpPath):
|
||||||
return QUrl.fromLocalFile(os.path.join(helpPath, '{}.html'.format(self.grass7Name))).toString()
|
return QUrl.fromLocalFile(os.path.join(helpPath, '{}.html'.format(self.grass_name))).toString()
|
||||||
else:
|
else:
|
||||||
return helpPath + '{}.html'.format(self.grass7Name)
|
return helpPath + '{}.html'.format(self.grass_name)
|
||||||
|
|
||||||
def initAlgorithm(self, config=None):
|
def initAlgorithm(self, config=None):
|
||||||
"""
|
"""
|
||||||
@ -254,7 +254,7 @@ class GrassAlgorithm(QgsProcessingAlgorithm):
|
|||||||
"""
|
"""
|
||||||
Create algorithm parameters and outputs from parsed description
|
Create algorithm parameters and outputs from parsed description
|
||||||
"""
|
"""
|
||||||
self.grass7Name = description.grass_command
|
self.grass_name = description.grass_command
|
||||||
self._name = description.name
|
self._name = description.name
|
||||||
self._short_description = description.short_description
|
self._short_description = description.short_description
|
||||||
self._display_name = description.display_name
|
self._display_name = description.display_name
|
||||||
@ -588,7 +588,7 @@ class GrassAlgorithm(QgsProcessingAlgorithm):
|
|||||||
# Add the default parameters commands
|
# Add the default parameters commands
|
||||||
self.commands.append(command)
|
self.commands.append(command)
|
||||||
|
|
||||||
QgsMessageLog.logMessage(self.tr('processInputs end. Commands: {}').format(self.commands), 'Grass7', Qgis.MessageLevel.Info)
|
QgsMessageLog.logMessage(self.tr('processInputs end. Commands: {}').format(self.commands), 'Grass', Qgis.MessageLevel.Info)
|
||||||
|
|
||||||
def processCommand(self, parameters, context, feedback, delOutputs=False):
|
def processCommand(self, parameters, context, feedback, delOutputs=False):
|
||||||
"""
|
"""
|
||||||
@ -598,7 +598,7 @@ class GrassAlgorithm(QgsProcessingAlgorithm):
|
|||||||
:param delOutputs: do not add outputs to commands.
|
:param delOutputs: do not add outputs to commands.
|
||||||
"""
|
"""
|
||||||
noOutputs = [o for o in self.parameterDefinitions() if o not in self.destinationParameterDefinitions()]
|
noOutputs = [o for o in self.parameterDefinitions() if o not in self.destinationParameterDefinitions()]
|
||||||
command = '{} '.format(self.grass7Name)
|
command = '{} '.format(self.grass_name)
|
||||||
command += '{}'.join(self.hardcodedStrings)
|
command += '{}'.join(self.hardcodedStrings)
|
||||||
|
|
||||||
# Add algorithm command
|
# Add algorithm command
|
||||||
@ -743,7 +743,7 @@ class GrassAlgorithm(QgsProcessingAlgorithm):
|
|||||||
|
|
||||||
command += ' --overwrite'
|
command += ' --overwrite'
|
||||||
self.commands.append(command)
|
self.commands.append(command)
|
||||||
QgsMessageLog.logMessage(self.tr('processCommands end. Commands: {}').format(self.commands), 'Grass7', Qgis.MessageLevel.Info)
|
QgsMessageLog.logMessage(self.tr('processCommands end. Commands: {}').format(self.commands), 'Grass', Qgis.MessageLevel.Info)
|
||||||
|
|
||||||
def vectorOutputType(self, parameters, context):
|
def vectorOutputType(self, parameters, context):
|
||||||
"""Determine vector output types for outputs"""
|
"""Determine vector output types for outputs"""
|
||||||
|
@ -161,7 +161,7 @@ class GrassProvider(QgsProcessingProvider):
|
|||||||
|
|
||||||
def supportsNonFileBasedOutput(self):
|
def supportsNonFileBasedOutput(self):
|
||||||
"""
|
"""
|
||||||
GRASS7 Provider doesn't support non file based outputs
|
GRASS Provider doesn't support non file based outputs
|
||||||
"""
|
"""
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@ -150,7 +150,7 @@ class GrassUtils:
|
|||||||
def grassBin():
|
def grassBin():
|
||||||
"""
|
"""
|
||||||
Find GRASS binary path on the operating system.
|
Find GRASS binary path on the operating system.
|
||||||
Sets global variable Grass7Utils.command
|
Sets global variable GrassUtils.command
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def searchFolder(folder):
|
def searchFolder(folder):
|
||||||
@ -223,7 +223,7 @@ class GrassUtils:
|
|||||||
def grassPath():
|
def grassPath():
|
||||||
"""
|
"""
|
||||||
Find GRASS path on the operating system.
|
Find GRASS path on the operating system.
|
||||||
Sets global variable Grass7Utils.path
|
Sets global variable GrassUtils.path
|
||||||
"""
|
"""
|
||||||
if GrassUtils.path is not None:
|
if GrassUtils.path is not None:
|
||||||
return GrassUtils.path
|
return GrassUtils.path
|
||||||
@ -543,7 +543,7 @@ class GrassUtils:
|
|||||||
# the layers.
|
# the layers.
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def endGrassSession():
|
def endGrassSession():
|
||||||
# shutil.rmtree(Grass7Utils.grassMapsetFolder(), True)
|
# shutil.rmtree(GrassUtils.grassMapsetFolder(), True)
|
||||||
GrassUtils.sessionRunning = False
|
GrassUtils.sessionRunning = False
|
||||||
GrassUtils.sessionLayers = {}
|
GrassUtils.sessionLayers = {}
|
||||||
GrassUtils.projectionSet = False
|
GrassUtils.projectionSet = False
|
||||||
@ -564,7 +564,7 @@ class GrassUtils:
|
|||||||
if GrassUtils.isGrassInstalled:
|
if GrassUtils.isGrassInstalled:
|
||||||
return
|
return
|
||||||
|
|
||||||
# We check the version of Grass7
|
# We check the version of Grass
|
||||||
if GrassUtils.installedVersion() is not None:
|
if GrassUtils.installedVersion() is not None:
|
||||||
# For Ms-Windows, we check GRASS binaries
|
# For Ms-Windows, we check GRASS binaries
|
||||||
if isWindows():
|
if isWindows():
|
||||||
|
@ -33,7 +33,7 @@ from grassprovider.grass_provider import GrassProvider
|
|||||||
from grassprovider.grass_utils import GrassUtils
|
from grassprovider.grass_utils import GrassUtils
|
||||||
|
|
||||||
|
|
||||||
class TestGrass7AlgorithmsImageryTest(QgisTestCase, AlgorithmsTestBase.AlgorithmsTest):
|
class TestGrassAlgorithmsImageryTest(QgisTestCase, AlgorithmsTestBase.AlgorithmsTest):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpClass(cls):
|
def setUpClass(cls):
|
||||||
@ -51,7 +51,7 @@ class TestGrass7AlgorithmsImageryTest(QgisTestCase, AlgorithmsTestBase.Algorithm
|
|||||||
shutil.rmtree(path)
|
shutil.rmtree(path)
|
||||||
|
|
||||||
def test_definition_file(self):
|
def test_definition_file(self):
|
||||||
return 'grass7_algorithms_imagery_tests.yaml'
|
return 'grass_algorithms_imagery_tests.yaml'
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
@ -34,7 +34,7 @@ from grassprovider.grass_provider import GrassProvider
|
|||||||
from grassprovider.grass_utils import GrassUtils
|
from grassprovider.grass_utils import GrassUtils
|
||||||
|
|
||||||
|
|
||||||
class TestGrass7AlgorithmsRasterTest(QgisTestCase, AlgorithmsTestBase.AlgorithmsTest):
|
class TestGrassAlgorithmsRasterTest(QgisTestCase, AlgorithmsTestBase.AlgorithmsTest):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpClass(cls):
|
def setUpClass(cls):
|
||||||
@ -52,7 +52,7 @@ class TestGrass7AlgorithmsRasterTest(QgisTestCase, AlgorithmsTestBase.Algorithms
|
|||||||
shutil.rmtree(path)
|
shutil.rmtree(path)
|
||||||
|
|
||||||
def test_definition_file(self):
|
def test_definition_file(self):
|
||||||
return 'grass7_algorithms_raster_tests1.yaml'
|
return 'grass_algorithms_raster_tests1.yaml'
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
@ -42,7 +42,7 @@ from grassprovider.grass_utils import GrassUtils
|
|||||||
testDataPath = os.path.join(os.path.dirname(__file__), 'testdata')
|
testDataPath = os.path.join(os.path.dirname(__file__), 'testdata')
|
||||||
|
|
||||||
|
|
||||||
class TestGrass7AlgorithmsRasterTest(QgisTestCase, AlgorithmsTestBase.AlgorithmsTest):
|
class TestGrassAlgorithmsRasterTest(QgisTestCase, AlgorithmsTestBase.AlgorithmsTest):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpClass(cls):
|
def setUpClass(cls):
|
||||||
@ -63,13 +63,13 @@ class TestGrass7AlgorithmsRasterTest(QgisTestCase, AlgorithmsTestBase.Algorithms
|
|||||||
shutil.rmtree(path)
|
shutil.rmtree(path)
|
||||||
|
|
||||||
def test_definition_file(self):
|
def test_definition_file(self):
|
||||||
return 'grass7_algorithms_raster_tests2.yaml'
|
return 'grass_algorithms_raster_tests2.yaml'
|
||||||
|
|
||||||
def testNeighbors(self):
|
def testNeighbors(self):
|
||||||
context = QgsProcessingContext()
|
context = QgsProcessingContext()
|
||||||
input_raster = os.path.join(testDataPath, 'custom', 'grass7', 'float_raster.tif')
|
input_raster = os.path.join(testDataPath, 'custom', 'grass7', 'float_raster.tif')
|
||||||
|
|
||||||
alg = QgsApplication.processingRegistry().createAlgorithmById('grass7:r.neighbors')
|
alg = QgsApplication.processingRegistry().createAlgorithmById('grass:r.neighbors')
|
||||||
self.assertIsNotNone(alg)
|
self.assertIsNotNone(alg)
|
||||||
|
|
||||||
temp_file = os.path.join(self.temp_dir, 'grass_output.tif')
|
temp_file = os.path.join(self.temp_dir, 'grass_output.tif')
|
||||||
|
@ -47,7 +47,7 @@ from grassprovider.grass_utils import GrassUtils
|
|||||||
testDataPath = os.path.join(os.path.dirname(__file__), 'testdata')
|
testDataPath = os.path.join(os.path.dirname(__file__), 'testdata')
|
||||||
|
|
||||||
|
|
||||||
class TestGrass7AlgorithmsVectorTest(QgisTestCase, AlgorithmsTestBase.AlgorithmsTest):
|
class TestGrassAlgorithmsVectorTest(QgisTestCase, AlgorithmsTestBase.AlgorithmsTest):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpClass(cls):
|
def setUpClass(cls):
|
||||||
@ -68,7 +68,7 @@ class TestGrass7AlgorithmsVectorTest(QgisTestCase, AlgorithmsTestBase.Algorithms
|
|||||||
shutil.rmtree(path)
|
shutil.rmtree(path)
|
||||||
|
|
||||||
def test_definition_file(self):
|
def test_definition_file(self):
|
||||||
return 'grass7_algorithms_vector_tests.yaml'
|
return 'grass_algorithms_vector_tests.yaml'
|
||||||
|
|
||||||
def testMemoryLayerInput(self):
|
def testMemoryLayerInput(self):
|
||||||
# create a memory layer and add to project and context
|
# create a memory layer and add to project and context
|
||||||
@ -88,7 +88,7 @@ class TestGrass7AlgorithmsVectorTest(QgisTestCase, AlgorithmsTestBase.Algorithms
|
|||||||
context = QgsProcessingContext()
|
context = QgsProcessingContext()
|
||||||
context.setProject(QgsProject.instance())
|
context.setProject(QgsProject.instance())
|
||||||
|
|
||||||
alg = QgsApplication.processingRegistry().createAlgorithmById('grass7:v.buffer')
|
alg = QgsApplication.processingRegistry().createAlgorithmById('grass:v.buffer')
|
||||||
self.assertIsNotNone(alg)
|
self.assertIsNotNone(alg)
|
||||||
|
|
||||||
temp_file = os.path.join(self.temp_dir, 'grass_output.shp')
|
temp_file = os.path.join(self.temp_dir, 'grass_output.shp')
|
||||||
@ -148,7 +148,7 @@ class TestGrass7AlgorithmsVectorTest(QgisTestCase, AlgorithmsTestBase.Algorithms
|
|||||||
context = QgsProcessingContext()
|
context = QgsProcessingContext()
|
||||||
context.setProject(QgsProject.instance())
|
context.setProject(QgsProject.instance())
|
||||||
|
|
||||||
alg = QgsApplication.processingRegistry().createAlgorithmById('grass7:v.buffer')
|
alg = QgsApplication.processingRegistry().createAlgorithmById('grass:v.buffer')
|
||||||
self.assertIsNotNone(alg)
|
self.assertIsNotNone(alg)
|
||||||
temp_file = os.path.join(self.temp_dir, 'grass_output_sel.shp')
|
temp_file = os.path.join(self.temp_dir, 'grass_output_sel.shp')
|
||||||
parameters = {'input': QgsProcessingFeatureSourceDefinition('testmem', True),
|
parameters = {'input': QgsProcessingFeatureSourceDefinition('testmem', True),
|
||||||
@ -202,7 +202,7 @@ class TestGrass7AlgorithmsVectorTest(QgisTestCase, AlgorithmsTestBase.Algorithms
|
|||||||
context = QgsProcessingContext()
|
context = QgsProcessingContext()
|
||||||
context.setProject(QgsProject.instance())
|
context.setProject(QgsProject.instance())
|
||||||
|
|
||||||
alg = QgsApplication.processingRegistry().createAlgorithmById('grass7:v.buffer')
|
alg = QgsApplication.processingRegistry().createAlgorithmById('grass:v.buffer')
|
||||||
self.assertIsNotNone(alg)
|
self.assertIsNotNone(alg)
|
||||||
|
|
||||||
temp_file = os.path.join(self.temp_dir, 'grass_output.gpkg')
|
temp_file = os.path.join(self.temp_dir, 'grass_output.gpkg')
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# Here is a list of grass7 algorithms without test units
|
# Here is a list of grass algorithms without test units
|
||||||
|
|
||||||
## Raster algorithms
|
## Raster algorithms
|
||||||
|
|
||||||
@ -99,4 +99,4 @@
|
|||||||
|
|
||||||
## Vector algorithms
|
## Vector algorithms
|
||||||
|
|
||||||
We need to handle gml for output and input for GRASS7 algorithms before creating tests !
|
We need to handle gml for output and input for GRASS algorithms before creating tests !
|
||||||
|
@ -117,7 +117,7 @@ class TestProcessingGeneral(QgisTestCase):
|
|||||||
self.assertIn('project', providers)
|
self.assertIn('project', providers)
|
||||||
self.assertIn('script', providers)
|
self.assertIn('script', providers)
|
||||||
self.assertIn('model', providers)
|
self.assertIn('model', providers)
|
||||||
self.assertIn('grass7', providers)
|
self.assertIn('grass', providers)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
@ -48,7 +48,6 @@ per-file-ignores =
|
|||||||
python/plugins/db_manager/dlg_sql_window.py:E722,
|
python/plugins/db_manager/dlg_sql_window.py:E722,
|
||||||
python/plugins/db_manager/table_viewer.py:E722,
|
python/plugins/db_manager/table_viewer.py:E722,
|
||||||
python/plugins/processing/algs/gdal/GdalUtils.py:E722,
|
python/plugins/processing/algs/gdal/GdalUtils.py:E722,
|
||||||
python/plugins/processing/algs/grass7/Grass7Utils.py:E722,
|
|
||||||
python/plugins/processing/algs/qgis/FieldPyculator.py:E722,
|
python/plugins/processing/algs/qgis/FieldPyculator.py:E722,
|
||||||
python/plugins/processing/algs/qgis/FindProjection.py:E722,
|
python/plugins/processing/algs/qgis/FindProjection.py:E722,
|
||||||
python/plugins/processing/algs/qgis/TextToFloat.py:E722,
|
python/plugins/processing/algs/qgis/TextToFloat.py:E722,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user