Projects/laydi
Projects
/
laydi
Archived
7
0
Fork 0

If argument 'selection' exists in function.run, pass current selection to it.

This commit is contained in:
Truls Alexander Tangstad 2006-05-05 13:10:54 +00:00
parent aa3a9ab619
commit 98445498b5
1 changed files with 20 additions and 8 deletions

View File

@ -177,8 +177,14 @@ class WorkflowView (gtk.VBox):
args, varargs, varkw, defaults = inspect.getargspec(function.run)
# first argument is 'self' and we don't care about that...
args = args[1:]
# first argument is 'self' and second should be the selection
# and we don't care about those...
args.remove('self')
if "selection" in args:
pass_selection = True
args.remove('selection')
else:
pass_selection = False
if varargs and len(parent_data) < len(args):
logger.log('warning', "Function requires minimum %d datasets selected." % len(args))
@ -188,14 +194,20 @@ class WorkflowView (gtk.VBox):
logger.log('warning', "Function requires %d datasets, but only %d selected." % (len(args), len(parent_data)))
return
# we allow functions requiring no data to be run even if
# something is selected
if not args:
new_data = function.run()
# we allow functions requiring no data to be run even if a
# dataset is is selected
data = []
else:
new_data = function.run(*parent_data)
data = parent_data
if pass_selection:
# if the function has a 'selection' argument, we pass in
# the selection
new_data = function.run(selection=project.get_selection(), *data)
else:
new_data = function.run(*data)
if new_data != None:
project.add_data(parent_data, new_data, function.name)