Skip to content

Commit

Permalink
runalg arguments by name
Browse files Browse the repository at this point in the history
git-svn-id: http://sextante.googlecode.com/svn/trunk/soft/bindings/qgis-plugin@253 881b9c09-3ef8-f3c2-ec3d-21d735c97f4d
  • Loading branch information
cpolymeris@gmail.com committed Jun 19, 2012
1 parent 1c0820b commit 4899de0
Showing 1 changed file with 20 additions and 10 deletions.
30 changes: 20 additions & 10 deletions src/sextante/core/Sextante.py
Expand Up @@ -255,20 +255,30 @@ def runalg(name, *args):
return

alg = alg.getCopy()#copy.deepcopy(alg)
i = 0
for param in alg.parameters:
if not param.setValue(args[i]):
print ("Error: Wrong parameter value: " + args[i])
if isinstance(args, dict):
# set params by name
for name, value in args.items():
if alg.getParameterFromName(name).setValue(value):
continue;
if alg.getOutputFromName(name).setValue(value):
continue;
print ("Error: Wrong parameter value %s for parameter %s." % (value, name))
return
i = i +1

for output in alg.outputs:
if not output.hidden:
if not output.setValue(args[i]):
print ("Error: Wrong output value: " + args[i])
else:
i = 0
for param in alg.parameters:
if not param.setValue(args[i]):
print ("Error: Wrong parameter value: " + args[i])
return
i = i +1

for output in alg.outputs:
if not output.hidden:
if not output.setValue(args[i]):
print ("Error: Wrong output value: " + args[i])
return
i = i +1

msg = alg.checkParameterValuesBeforeExecuting()
if msg:
print ("Unable to execute algorithm\n" + msg)
Expand Down

0 comments on commit 4899de0

Please sign in to comment.