Commit 5c7bdf2a authored by Floreal Cabanettes's avatar Floreal Cabanettes
Browse files

Fix bug on rules

parent 2fd75d22
......@@ -30,6 +30,15 @@ from jflow.exceptions import RuleException, RuleIgnore
class SimpleRule (ABC):
def get_parameter(self, src_arg):
if ">" not in src_arg:
wf_parameter = getattr(self.wf_instance, src_arg)
else:
wf_parameter = getattr(self.wf_instance, src_arg[:src_arg.index(">")]).\
get_sub_parameters_by_name()[src_arg[src_arg.index(">")+1:]][0]
return wf_parameter
def __init__(self, user_args, wf_instance, src_arg, nb_rows):
self.user_args = user_args
self.wf_instance = wf_instance
......@@ -147,7 +156,10 @@ class Exclude(LinkRule):
def check(self):
for exclude in self.targets_args:
if exclude in self.user_args and self.user_args[exclude] is not None: # The target is found
if exclude in self.user_args and self.user_args[exclude] is not None and self.user_args[exclude] and \
self.user_args[exclude] != self.get_parameter(exclude).default:
# The target is found, is not None and is not False
print(self.user_args)
self.error("Parameters '" + self.parameter_name + "' and '" + exclude + "' are mutually excluded")
......@@ -158,8 +170,9 @@ class ToBeRequired(LinkRule):
def check(self):
for require in self.targets_args:
if require not in self.user_args or (require in self.user_args and self.user_args[require] is None): # The
# target is not found
if require not in self.user_args or (require in self.user_args and (self.user_args[require] is None
or not self.user_args[require])):
# The target is not found
self.error("Parameter '" + self.parameter_name + "' require parameter '" + require +
"' to be defined")
......@@ -183,8 +196,9 @@ class DisabledIf(ConditionalRule):
def check(self):
if self.condition_raised and self.parameter_name in self.user_args and \
self.user_args[self.parameter_name] is not None and \
str(self.user_args[self.parameter_name]) != str(self.wf_instance.__dict__[self.parameter_name].default):
self.error("Parameter '" + self.parameter_name + "' is not available, because: " + self.condition_raised_name)
str(self.user_args[self.parameter_name]) != str(self.get_parameter(self.parameter_name).default):
self.error("Parameter '" + self.parameter_name + "' is not available, because: " +
self.condition_raised_name)
class FilesUnique(SimpleRule):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment