Validation on number of inputs added
This commit is contained in:
@@ -114,12 +114,19 @@ class Function:
|
||||
self.id = id
|
||||
self.name = name
|
||||
|
||||
def valid_input(input):
|
||||
return True
|
||||
# ,ust return a Validation object
|
||||
def validate_input(input):
|
||||
return Validation(True,"Validation Not Implemented")
|
||||
|
||||
def run(self, data):
|
||||
def run(self):
|
||||
pass
|
||||
|
||||
class Validation:
|
||||
def __init__(self,result, reason):
|
||||
self.succeeded = result
|
||||
self.reason = reason
|
||||
|
||||
|
||||
class WorkflowView (gtk.VBox):
|
||||
|
||||
def __init__(self, wf):
|
||||
@@ -162,10 +169,25 @@ class WorkflowView (gtk.VBox):
|
||||
project = self.workflow.app.project
|
||||
parent_data = project.current_data
|
||||
|
||||
new_data = function.run(project.current_data)
|
||||
validation = function.validate_input()
|
||||
|
||||
if not validation.succeeded:
|
||||
logger.log('warning','Invalid Inputdata: ' + str(reason))
|
||||
return
|
||||
|
||||
argcount =function.run.func_code.co_argcount - 1
|
||||
|
||||
if argcount != len(parent_data):
|
||||
logger.log('warning','Method requires ' + str(argcount) + ' Data. ' + str(len(parent_data)) + ' selected')
|
||||
return
|
||||
if not project.current_data:
|
||||
new_data = function.run()
|
||||
else:
|
||||
new_data = function.run(*project.current_data)
|
||||
|
||||
if new_data != None:
|
||||
project.add_data(parent_data, new_data, function.name)
|
||||
|
||||
|
||||
logger.log('debug', 'Function ended: %s' % function.name)
|
||||
|
||||
def button_click_handler(self, button):
|
||||
|
Reference in New Issue
Block a user