Skip to content

Commit

Permalink
[processing] minor fix in parameter parsing in scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
volaya committed Nov 6, 2015
1 parent 227af8a commit 9f3bd1d
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions python/plugins/processing/script/ScriptAlgorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,20 +145,20 @@ def processParameterLine(self, line):
if tokens[1].lower().strip() == 'name':
self.name = self.i18n_name = tokens[0]
return

if tokens[1].lower().strip().startswith('output'):
outToken = tokens[1].strip()[len('output') + 1:]
out = self.processOutputParameterToken(outToken)

elif tokens[1].lower().strip().startswith('optional'):
optToken = tokens[1].strip()[len('optional') + 1:]
param = self.processInputParameterToken(optToken, tokens[0])
if param:
param.optional = True

else:
param = self.processInputParameterToken(tokens[1], tokens[0])


if param is not None:
self.addParameter(param)
Expand All @@ -173,9 +173,9 @@ def processParameterLine(self, line):

def processInputParameterToken(self, token, name):
param = None

descName = self.createDescriptiveName(name)

if token.lower().strip() == 'raster':
param = ParameterRaster(name, descName, False)
elif token.lower().strip() == 'vector':
Expand Down Expand Up @@ -204,7 +204,7 @@ def processInputParameterToken(self, token, name):
options = token.strip()[len('selectionfromfile '):].split(';')
param = ParameterSelection(name, descName, options, isSource=True)
elif token.lower().strip().startswith('selection'):
options = tokens[1].strip()[len('selection '):].split(';')
options = token.strip()[len('selection '):].split(';')
param = ParameterSelection(name, descName, options)
elif token.lower().strip().startswith('boolean'):
default = token.strip()[len('boolean') + 1:]
Expand Down Expand Up @@ -238,12 +238,12 @@ def processInputParameterToken(self, token, name):
if not default:
default = 'EPSG:4326'
param = ParameterCrs(name, descName, default)

return param

def processOutputParameterToken(self, token):
out = None

if token.lower().strip().startswith('raster'):
out = OutputRaster()
elif token.lower().strip().startswith('vector'):
Expand All @@ -263,7 +263,7 @@ def processOutputParameterToken(self, token):
out = OutputNumber()
elif token.lower().strip().startswith('string'):
out = OutputString()

return out

def processDescriptionParameterLine(self, line):
Expand Down

0 comments on commit 9f3bd1d

Please sign in to comment.