Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
genotoul-bioinfo
jflow
Commits
f0ec396c
Commit
f0ec396c
authored
Jan 25, 2017
by
Floreal Cabanettes
Browse files
Add ValueRules + ForbiddenChars rule
parent
33a9d88d
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/jflow/rules.py
View file @
f0ec396c
...
...
@@ -99,6 +99,20 @@ class LinkRule (SimpleRule):
def
check
(
self
):
pass
class
ValueRule
(
SimpleRule
):
def
__init__
(
self
,
user_args
,
wf_instance
,
src_arg
,
values_arg
,
nb_rows
):
SimpleRule
.
__init__
(
self
,
user_args
,
wf_instance
,
src_arg
,
nb_rows
)
values
=
values_arg
.
replace
(
"\,"
,
"###virgule###"
)
values
=
values
.
split
(
","
)
all_values
=
[]
for
val
in
values
:
all_values
.
append
(
val
.
replace
(
"###virgule###"
,
","
))
self
.
values_arg
=
all_values
@
abstractmethod
def
check
(
self
):
pass
class
ConditionalRule
(
SimpleRule
):
def
__init__
(
self
,
user_args
,
wf_instance
,
src_arg
,
conditions
,
which
,
nb_rows
):
...
...
@@ -218,4 +232,15 @@ class FilesUnique(SimpleRule):
if
isinstance
(
sub_parameter_obj
,
InputFile
)
or
isinstance
(
sub_parameter_obj
,
InputDirectory
):
all_files
+=
value
if
len
(
set
(
all_files
))
<
len
(
all_files
):
self
.
error
(
"Some files into '"
+
self
.
parameter_name
+
"' are given several times"
)
\ No newline at end of file
self
.
error
(
"Some files into '"
+
self
.
parameter_name
+
"' are given several times"
)
class
ForbiddenChars
(
ValueRule
):
"""
Some characters are not allowed
"""
def
check
(
self
):
for
value
in
self
.
values_arg
:
if
value
in
self
.
parameter_value
:
self
.
error
(
"Character not allowed:
\"
"
+
value
+
"
\"
"
)
src/jflow/workflow.py
View file @
f0ec396c
...
...
@@ -1352,9 +1352,13 @@ class Workflow(threading.Thread):
raise
Exception
(
"Rule is not defined: "
+
name
)
# Launch validator
if
issubclass
(
validator_class
,
j_rules
.
LinkRule
):
# Check the rule is the same special rule
if
issubclass
(
validator_class
,
j_rules
.
LinkRule
):
# Check the rule is the same special rule
validator
=
validator_class
(
user_args
,
self
,
src_arg
,
targets
,
nb_rows
)
validator
.
check
()
elif
issubclass
(
validator_class
,
j_rules
.
ValueRule
):
validator
=
validator_class
(
user_args
,
self
,
src_arg
,
is_link_rule
.
group
(
2
),
nb_rows
)
validator
.
check
()
else
:
raise
Exception
(
"Rule is not a link rule: "
+
name
)
else
:
# It's a simple rule
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment