From df329bceaba814344f3ce8b51fd1838f753e8774 Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Mon, 26 Jun 2017 15:47:51 +1000 Subject: [PATCH] Start restoring creation of outputs from string --- python/plugins/processing/core/outputs.py | 68 +++++++++++++---------- 1 file changed, 40 insertions(+), 28 deletions(-) diff --git a/python/plugins/processing/core/outputs.py b/python/plugins/processing/core/outputs.py index 2e41a193d7f..ad81308f02a 100644 --- a/python/plugins/processing/core/outputs.py +++ b/python/plugins/processing/core/outputs.py @@ -46,7 +46,13 @@ from qgis.core import (QgsExpressionContext, QgsSettings, QgsVectorFileWriter, QgsProcessingUtils, - QgsProcessingParameterDefinition) + QgsProcessingParameterDefinition, + QgsProcessingOutputRasterLayer, + QgsProcessingOutputVectorLayer, + QgsProcessingOutputHtml, + QgsProcessingOutputNumber, + QgsProcessingOutputString, + QgsProcessingOutputFolder) def _expressionContext(alg): @@ -393,36 +399,42 @@ def getOutputFromString(s): return clazz(*params) else: tokens = s.split("=") + if not tokens[1].lower()[:len('output')] == 'output': + return None + + name = tokens[0] + description = tokens[0] + token = tokens[1].strip()[len('output') + 1:] out = None - if token.lower().strip().startswith('raster'): - out = OutputRaster() - elif token.lower().strip() == 'vector': - out = OutputVector() - elif token.lower().strip() == 'vector point': - out = OutputVector(datatype=[dataobjects.TYPE_VECTOR_POINT]) - elif token.lower().strip() == 'vector line': - out = OutputVector(datatype=[OutputVector.TYPE_VECTOR_LINE]) - elif token.lower().strip() == 'vector polygon': - out = OutputVector(datatype=[OutputVector.TYPE_VECTOR_POLYGON]) - elif token.lower().strip().startswith('table'): - out = OutputTable() - elif token.lower().strip().startswith('html'): - out = OutputHTML() - elif token.lower().strip().startswith('file'): - out = OutputFile() - ext = token.strip()[len('file') + 1:] - if ext: - out.ext = ext - elif token.lower().strip().startswith('directory'): - out = OutputDirectory() - elif token.lower().strip().startswith('number'): - out = OutputNumber() - elif token.lower().strip().startswith('string'): - out = OutputString() - elif token.lower().strip().startswith('extent'): - out = OutputExtent() + if token.lower().strip().startswith('outputraster'): + out = QgsProcessingOutputRasterLayer(name, description) + elif token.lower().strip() == 'outputvector': + out = QgsProcessingOutputVectorLayer(name, description) +# elif token.lower().strip() == 'vector point': +# out = OutputVector(datatype=[dataobjects.TYPE_VECTOR_POINT]) +# elif token.lower().strip() == 'vector line': +# out = OutputVector(datatype=[OutputVector.TYPE_VECTOR_LINE]) +# elif token.lower().strip() == 'vector polygon': +# out = OutputVector(datatype=[OutputVector.TYPE_VECTOR_POLYGON]) +# elif token.lower().strip().startswith('table'): +# out = OutputTable() + elif token.lower().strip().startswith('outputhtml'): + out = QgsProcessingOutputHtml(name, description) +# elif token.lower().strip().startswith('file'): +# out = OutputFile() +# ext = token.strip()[len('file') + 1:] +# if ext: +# out.ext = ext + elif token.lower().strip().startswith('outputfolder'): + out = QgsProcessingOutputFolder(name, description) + elif token.lower().strip().startswith('outputnumber'): + out = QgsProcessingOutputNumber(name, description) + elif token.lower().strip().startswith('outputstring'): + out = QgsProcessingOutputString(name, description) +# elif token.lower().strip().startswith('extent'): +# out = OutputExtent() return out except: