Commit 24f0b196 authored by Floreal Cabanettes's avatar Floreal Cabanettes
Browse files

Merge branch 'master' into dev

parents 32733637 5c7bdf2a
...@@ -30,6 +30,15 @@ from jflow.exceptions import RuleException, RuleIgnore ...@@ -30,6 +30,15 @@ from jflow.exceptions import RuleException, RuleIgnore
class SimpleRule (ABC): 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): def __init__(self, user_args, wf_instance, src_arg, nb_rows):
self.user_args = user_args self.user_args = user_args
self.wf_instance = wf_instance self.wf_instance = wf_instance
...@@ -147,7 +156,10 @@ class Exclude(LinkRule): ...@@ -147,7 +156,10 @@ class Exclude(LinkRule):
def check(self): def check(self):
for exclude in self.targets_args: 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") self.error("Parameters '" + self.parameter_name + "' and '" + exclude + "' are mutually excluded")
...@@ -158,8 +170,9 @@ class ToBeRequired(LinkRule): ...@@ -158,8 +170,9 @@ class ToBeRequired(LinkRule):
def check(self): def check(self):
for require in self.targets_args: 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 if require not in self.user_args or (require in self.user_args and (self.user_args[require] is None
# target is not found or not self.user_args[require])):
# The target is not found
self.error("Parameter '" + self.parameter_name + "' require parameter '" + require + self.error("Parameter '" + self.parameter_name + "' require parameter '" + require +
"' to be defined") "' to be defined")
...@@ -183,8 +196,9 @@ class DisabledIf(ConditionalRule): ...@@ -183,8 +196,9 @@ class DisabledIf(ConditionalRule):
def check(self): def check(self):
if self.condition_raised and self.parameter_name in self.user_args and \ if self.condition_raised and self.parameter_name in self.user_args and \
self.user_args[self.parameter_name] is not None 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): 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) self.error("Parameter '" + self.parameter_name + "' is not available, because: " +
self.condition_raised_name)
class FilesUnique(SimpleRule): 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