Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
genotoul-bioinfo
ng6
Commits
e42d9f1a
Commit
e42d9f1a
authored
Oct 10, 2013
by
Jerome Mariette
Browse files
fix a bug with bool sub parameters type
parent
d346f2dc
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/jflow/parameter.py
View file @
e42d9f1a
...
...
@@ -25,26 +25,33 @@ from workflows.types import *
class
MiltipleParameters
(
object
):
def
__init__
(
self
,
types
,
required
,
choices
,
excludes
):
def
__init__
(
self
,
types
,
required
,
choices
,
excludes
,
default
):
self
.
types
=
types
self
.
choices
=
choices
self
.
excludes
=
excludes
self
.
default
=
default
self
.
index
=
None
self
.
required
=
required
self
.
__name__
=
"MiltipleParameters"
def
__call__
(
self
,
arg
):
parts
=
arg
.
split
(
"="
)
if
not
self
.
types
.
has_key
(
parts
[
0
]):
raise
argparse
.
ArgumentTypeError
(
parts
[
0
]
+
" is an invalid flag! Available ones are: "
+
", "
.
join
(
self
.
types
.
keys
()))
if
self
.
choices
[
parts
[
0
]]
!=
None
:
if
parts
[
1
]
not
in
self
.
choices
[
parts
[
0
]]:
raise
argparse
.
ArgumentTypeError
(
"argument "
+
parts
[
0
]
+
": invalid choice: '"
+
parts
[
1
]
+
"' (choose from "
+
", "
.
join
(
self
.
choices
[
parts
[
0
]])
+
"))"
)
try
:
value
=
self
.
types
[
parts
[
0
]](
parts
[
1
])
except
:
raise
argparse
.
ArgumentTypeError
(
"invalid "
+
self
.
types
[
parts
[
0
]].
__name__
+
" value: '"
+
parts
[
1
]
+
"' for sub parameter '"
+
parts
[
0
]
+
"'"
)
self
.
index
=
parts
[
0
]
return
(
parts
[
0
],
value
,
self
.
required
,
self
.
excludes
)
if
self
.
types
[
parts
[
0
]]
==
types
.
BooleanType
:
return
(
parts
[
0
],
not
self
.
default
[
parts
[
0
]],
self
.
required
,
self
.
excludes
)
else
:
try
:
value
=
self
.
types
[
parts
[
0
]](
parts
[
1
])
except
:
raise
argparse
.
ArgumentTypeError
(
"invalid "
+
self
.
types
[
parts
[
0
]].
__name__
+
" value: '"
+
parts
[
1
]
+
"' for sub parameter '"
+
parts
[
0
]
+
"'"
)
self
.
index
=
parts
[
0
]
return
(
parts
[
0
],
value
,
self
.
required
,
self
.
excludes
)
class
MiltipleAction
(
argparse
.
Action
):
def
__call__
(
self
,
parser
,
namespace
,
values
,
option_string
=
None
):
...
...
@@ -169,6 +176,7 @@ class Parameter(object):
self
.
type
=
date
elif
type
==
"multiple"
:
sub_param_hash
,
sub_param_types
,
sub_param_names
,
sub_param_required
,
sub_param_choices
,
sub_param_excludes
=
{},
[],
[],
[],
{},
{}
sub_param_default
=
{}
for
sub_param
in
self
.
sub_parameters
:
try
:
sub_type
=
sub_param
.
type
except
:
sub_type
=
types
.
StringType
...
...
@@ -176,13 +184,14 @@ class Parameter(object):
sub_param_names
.
append
(
sub_param
.
flag
)
sub_param_types
.
append
(
sub_type
)
sub_param_choices
[
sub_param
.
flag
]
=
sub_param
.
choices
sub_param_default
[
sub_param
.
flag
]
=
sub_param
.
default
if
sub_param
.
group
.
startswith
(
"exclude-"
):
if
sub_param
.
group
in
sub_param_excludes
.
keys
():
sub_param_excludes
[
sub_param
.
group
].
append
(
sub_param
.
flag
)
else
:
sub_param_excludes
[
sub_param
.
group
]
=
[
sub_param
.
flag
]
if
sub_param
.
required
:
sub_param_required
.
append
(
sub_param
.
flag
)
self
.
type
=
MiltipleParameters
(
sub_param_hash
,
sub_param_required
,
sub_param_choices
,
sub_param_excludes
)
self
.
type
=
MiltipleParameters
(
sub_param_hash
,
sub_param_required
,
sub_param_choices
,
sub_param_excludes
,
sub_param_default
)
if
self
.
action
==
"append"
:
self
.
action
=
MiltipleAppendAction
else
:
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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