Skip to content
Permalink
Browse files

runalg arguments by name

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
cpolymeris@gmail.com committed Jun 19, 2012
1 parent 1c0820b commit 4899de01334a69ee65a72d6e637d9face49edc67
Showing with 20 additions and 10 deletions.
  1. +20 −10 src/sextante/core/Sextante.py
@@ -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)

0 comments on commit 4899de0

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