Skip to content
Permalink
Browse files

Start restoring creation of outputs from string

  • Loading branch information
nyalldawson committed Jun 26, 2017
1 parent f13920b commit df329bceaba814344f3ce8b51fd1838f753e8774
Showing with 40 additions and 28 deletions.
  1. +40 −28 python/plugins/processing/core/outputs.py
@@ -46,7 +46,13 @@
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:

0 comments on commit df329bc

Please sign in to comment.
You can’t perform that action at this time.