Skip to content

Commit df329bc

Browse files
committedJun 26, 2017
Start restoring creation of outputs from string
1 parent f13920b commit df329bc

File tree

1 file changed

+40
-28
lines changed

1 file changed

+40
-28
lines changed
 

‎python/plugins/processing/core/outputs.py

Lines changed: 40 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,13 @@
4646
QgsSettings,
4747
QgsVectorFileWriter,
4848
QgsProcessingUtils,
49-
QgsProcessingParameterDefinition)
49+
QgsProcessingParameterDefinition,
50+
QgsProcessingOutputRasterLayer,
51+
QgsProcessingOutputVectorLayer,
52+
QgsProcessingOutputHtml,
53+
QgsProcessingOutputNumber,
54+
QgsProcessingOutputString,
55+
QgsProcessingOutputFolder)
5056

5157

5258
def _expressionContext(alg):
@@ -393,36 +399,42 @@ def getOutputFromString(s):
393399
return clazz(*params)
394400
else:
395401
tokens = s.split("=")
402+
if not tokens[1].lower()[:len('output')] == 'output':
403+
return None
404+
405+
name = tokens[0]
406+
description = tokens[0]
407+
396408
token = tokens[1].strip()[len('output') + 1:]
397409
out = None
398410

399-
if token.lower().strip().startswith('raster'):
400-
out = OutputRaster()
401-
elif token.lower().strip() == 'vector':
402-
out = OutputVector()
403-
elif token.lower().strip() == 'vector point':
404-
out = OutputVector(datatype=[dataobjects.TYPE_VECTOR_POINT])
405-
elif token.lower().strip() == 'vector line':
406-
out = OutputVector(datatype=[OutputVector.TYPE_VECTOR_LINE])
407-
elif token.lower().strip() == 'vector polygon':
408-
out = OutputVector(datatype=[OutputVector.TYPE_VECTOR_POLYGON])
409-
elif token.lower().strip().startswith('table'):
410-
out = OutputTable()
411-
elif token.lower().strip().startswith('html'):
412-
out = OutputHTML()
413-
elif token.lower().strip().startswith('file'):
414-
out = OutputFile()
415-
ext = token.strip()[len('file') + 1:]
416-
if ext:
417-
out.ext = ext
418-
elif token.lower().strip().startswith('directory'):
419-
out = OutputDirectory()
420-
elif token.lower().strip().startswith('number'):
421-
out = OutputNumber()
422-
elif token.lower().strip().startswith('string'):
423-
out = OutputString()
424-
elif token.lower().strip().startswith('extent'):
425-
out = OutputExtent()
411+
if token.lower().strip().startswith('outputraster'):
412+
out = QgsProcessingOutputRasterLayer(name, description)
413+
elif token.lower().strip() == 'outputvector':
414+
out = QgsProcessingOutputVectorLayer(name, description)
415+
# elif token.lower().strip() == 'vector point':
416+
# out = OutputVector(datatype=[dataobjects.TYPE_VECTOR_POINT])
417+
# elif token.lower().strip() == 'vector line':
418+
# out = OutputVector(datatype=[OutputVector.TYPE_VECTOR_LINE])
419+
# elif token.lower().strip() == 'vector polygon':
420+
# out = OutputVector(datatype=[OutputVector.TYPE_VECTOR_POLYGON])
421+
# elif token.lower().strip().startswith('table'):
422+
# out = OutputTable()
423+
elif token.lower().strip().startswith('outputhtml'):
424+
out = QgsProcessingOutputHtml(name, description)
425+
# elif token.lower().strip().startswith('file'):
426+
# out = OutputFile()
427+
# ext = token.strip()[len('file') + 1:]
428+
# if ext:
429+
# out.ext = ext
430+
elif token.lower().strip().startswith('outputfolder'):
431+
out = QgsProcessingOutputFolder(name, description)
432+
elif token.lower().strip().startswith('outputnumber'):
433+
out = QgsProcessingOutputNumber(name, description)
434+
elif token.lower().strip().startswith('outputstring'):
435+
out = QgsProcessingOutputString(name, description)
436+
# elif token.lower().strip().startswith('extent'):
437+
# out = OutputExtent()
426438

427439
return out
428440
except:

0 commit comments

Comments
 (0)
Please sign in to comment.