Skip to content
Permalink
Browse files

[Processing] Fix default value support in script

For some parameters like Number if no default is set script is invalid.
  • Loading branch information
rldhont committed Jan 15, 2016
1 parent e20cfc0 commit 322e511797928111549bef25509fb6c68216e9d9
Showing with 20 additions and 7 deletions.
  1. +20 −7 python/plugins/processing/script/ScriptAlgorithm.py
@@ -217,7 +217,10 @@ def processInputParameterToken(self, token, name):
param = ParameterSelection(name, descName, options)
elif token.lower().strip().startswith('boolean'):
default = token.strip()[len('boolean') + 1:]
param = ParameterBoolean(name, descName, default)
if default:
param = ParameterBoolean(name, descName, default)
else:
param = ParameterBoolean(name, descName)
elif token.lower().strip() == 'extent':
param = ParameterExtent(name, descName)
elif token.lower().strip() == 'file':
@@ -226,7 +229,10 @@ def processInputParameterToken(self, token, name):
param = ParameterFile(name, descName, True)
elif token.lower().strip().startswith('number'):
default = token.strip()[len('number') + 1:]
param = ParameterNumber(name, descName, default=default)
if default:
param = ParameterNumber(name, descName, default=default)
else:
param = ParameterNumber(name, descName)
elif token.lower().strip().startswith('field'):
field = token.strip()[len('field') + 1:]
found = False
@@ -238,15 +244,22 @@ def processInputParameterToken(self, token, name):
param = ParameterTableField(name, descName, field)
elif token.lower().strip().startswith('string'):
default = token.strip()[len('string') + 1:]
param = ParameterString(name, descName, default)
if default:
param = ParameterString(name, descName, default)
else:
param = ParameterString(name, descName)
elif token.lower().strip().startswith('longstring'):
default = token.strip()[len('longstring') + 1:]
param = ParameterString(name, descName, default, multiline=True)
if default:
param = ParameterString(name, descName, default, multiline=True)
else:
param = ParameterString(name, descName, multiline=True)
elif token.lower().strip().startswith('crs'):
default = token.strip()[len('crs') + 1:]
if not default:
default = 'EPSG:4326'
param = ParameterCrs(name, descName, default)
if default:
param = ParameterCrs(name, descName, default)
else:
param = ParameterCrs(name, descName)

return param

0 comments on commit 322e511

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