Navigation Menu

Skip to content

Commit

Permalink
Handle parameters and update description files (WIP)
Browse files Browse the repository at this point in the history
  • Loading branch information
Médéric RIBREUX committed Nov 4, 2017
1 parent 733218c commit a676db2
Show file tree
Hide file tree
Showing 318 changed files with 2,210 additions and 2,073 deletions.
83 changes: 50 additions & 33 deletions python/plugins/processing/algs/grass7/Grass7Algorithm.py
Expand Up @@ -27,6 +27,7 @@

__revision__ = '$Format:%H$'

import sys
import os
import uuid
import importlib
Expand All @@ -41,29 +42,38 @@
QgsProcessingParameterDefinition,
QgsProcessingException,
QgsProcessingParameterExtent,
QgsProcessingParameterNumber)
QgsProcessingParameterNumber,
QgsProcessingParameterString,
QgsProcessingParameterPoint,
QgsProcessingParameterBoolean,
QgsProcessingParameterVectorLayer,
QgsProcessingParameterRasterLayer,
QgsProcessingParameterMultipleLayers,
QgsProcessingOutputVectorLayer,
QgsProcessingOutputRasterLayer,
QgsProcessingOutputHtml)
from qgis.utils import iface

#from processing.core.GeoAlgorithm import GeoAlgorithm (replaced by QgsProcessingAlgorithm)
from processing.core.ProcessingConfig import ProcessingConfig
#from processing.core.GeoAlgorithmExecutionException import GeoAlgorithmExecutionException (replaced by QgsProcessingException).

from processing.core.parameters import (getParameterFromString,
ParameterVector,
ParameterMultipleInput,
from processing.core.parameters import (getParameterFromString)
#ParameterVector,
#ParameterMultipleInput,
#ParameterExtent,
#ParameterNumber,
#ParameterSelection,
ParameterRaster,
ParameterTable,
ParameterBoolean,
ParameterString,
ParameterPoint)
from processing.core.outputs import (getOutputFromString,
OutputRaster,
OutputVector,
OutputFile,
OutputHTML)
#ParameterRaster,
#ParameterTable,
#ParameterBoolean,
#ParameterString,
#ParameterPoint)
#from processing.core.outputs import (getOutputFromString,
# OutputRaster,
# OutputVector,
# OutputFile,
# OutputHTML)

from .Grass7Utils import Grass7Utils

Expand Down Expand Up @@ -91,6 +101,7 @@ def __init__(self, descriptionfile):
self._display_name = ''
self._group = ''
self.grass7Name = ''
self.params = []
self.hardcodedStrings = []
self.descriptionFile = descriptionfile
self.defineCharacteristicsFromFile()
Expand Down Expand Up @@ -152,6 +163,10 @@ def getParameterDescriptions(self):
except Exception:
pass
return descs

def initAlgorithm(self, config=None):
for p in self.params:
self.addParameter(p)

def defineCharacteristicsFromFile(self):
"""
Expand Down Expand Up @@ -186,23 +201,23 @@ def defineCharacteristicsFromFile(self):
self.hardcodedStrings.append(line[len('Hardcoded|'):])
parameter = getParameterFromString(line)
if parameter is not None:
self.addParameter(parameter)
if isinstance(parameter, ParameterVector):
self.params.append(parameter)
if isinstance(parameter, QgsProcessingParameterVectorLayer):
hasVectorInput = True
if isinstance(parameter, ParameterMultipleInput) \
and parameter.datatype < 3:
if isinstance(parameter, QgsProcessingParameterMultipleLayers) \
and parameter.layerType() < 3:
hasVectorInput = True
else:
output = getOutputFromString(line)
self.addOutput(output)
if isinstance(output, OutputRaster):
hasRasterOutput = True
elif isinstance(output, OutputVector):
vectorOutputs += 1
if isinstance(output, OutputHTML):
self.addOutput(OutputFile("rawoutput",
self.tr("{0} (raw output)").format(output.description()),
"txt"))
#else:
# output = Grass7Utils.getOutputFromString(line)
# self.addOutput(output)
# if isinstance(output, QgsProcessingOutputRasterLayer):
# hasRasterOutput = True
# elif isinstance(output, QgsProcessingOutputVectorLayer):
# vectorOutputs += 1
# if isinstance(output, QgsProcessingOutputHtml):
# self.addOutput(OutputFile("rawoutput",