Skip to content

Commit

Permalink
[Processing] Fix default value support in script
Browse files Browse the repository at this point in the history
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 322e511
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions python/plugins/processing/script/ScriptAlgorithm.py
Expand Up @@ -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':
Expand All @@ -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
Expand All @@ -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

Expand Down

0 comments on commit 322e511

Please sign in to comment.