Skip to content

Commit

Permalink
Start restoring creation of outputs from string
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Jun 26, 2017
1 parent f13920b commit df329bc
Showing 1 changed file with 40 additions and 28 deletions.
68 changes: 40 additions & 28 deletions python/plugins/processing/core/outputs.py
Expand Up @@ -46,7 +46,13 @@
QgsSettings,
QgsVectorFileWriter,
QgsProcessingUtils,
QgsProcessingParameterDefinition)
QgsProcessingParameterDefinition,
QgsProcessingOutputRasterLayer,
QgsProcessingOutputVectorLayer,
QgsProcessingOutputHtml,
QgsProcessingOutputNumber,
QgsProcessingOutputString,
QgsProcessingOutputFolder)


def _expressionContext(alg):
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit df329bc

Please sign in to comment.