mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-14 00:07:35 -04:00
Start restoring creation of outputs from string
This commit is contained in:
parent
f13920bb19
commit
df329bceab
@ -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:
|
||||
|
Loading…
x
Reference in New Issue
Block a user