diff --git a/system/workflow.py b/system/workflow.py index 6780224..b993a2d 100644 --- a/system/workflow.py +++ b/system/workflow.py @@ -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)