Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
VIGNET Pierre
cadbiom
Commits
043c2e0e
Commit
043c2e0e
authored
Dec 03, 2016
by
VIGNET Pierre
Browse files
Ability to detect wrong output directory
parent
cbf091cd
Changes
1
Hide whitespace changes
Inline
Side-by-side
script_mac.py
View file @
043c2e0e
...
...
@@ -306,7 +306,10 @@ def compute_macs(args):
MODEL_NAME
=
params
[
'chart_file'
].
split
(
'/'
)[
-
1
][:
-
4
]
# FILES
CAM_FILE_PREFIX
=
params
[
'output'
]
+
MODEL_NAME
+
\
# Add trailing '/' if not present
output
=
params
[
'output'
]
if
params
[
'output'
][
-
1
]
==
'/'
\
else
params
[
'output'
]
+
'/'
CAM_FILE_PREFIX
=
output
+
MODEL_NAME
+
\
'_'
+
params
[
'final_prop'
]
+
'_cam'
# cam_file
cam_file
=
CAM_FILE_PREFIX
+
".txt"
...
...
@@ -345,6 +348,25 @@ def args_to_param(args):
return
{
k
:
v
for
k
,
v
in
vars
(
args
).
items
()
if
k
!=
'func'
}
class
readable_dir
(
argparse
.
Action
):
"""
http://stackoverflow.com/questions/11415570/directory-path-types-with-argparse
"""
def
__call__
(
self
,
parser
,
namespace
,
values
,
option_string
=
None
):
prospective_dir
=
values
if
not
os
.
path
.
isdir
(
prospective_dir
):
raise
argparse
.
ArgumentTypeError
(
"readable_dir:{0} is not a valid path"
.
format
(
prospective_dir
))
if
os
.
access
(
prospective_dir
,
os
.
R_OK
):
setattr
(
namespace
,
self
.
dest
,
prospective_dir
)
else
:
raise
argparse
.
ArgumentTypeError
(
"readable_dir:{0} is not a readable dir"
.
format
(
prospective_dir
))
if
__name__
==
"__main__"
:
# parser configuration
...
...
@@ -367,7 +389,8 @@ if __name__ == "__main__":
parser_input_file
.
add_argument
(
'--steps'
,
type
=
int
,
nargs
=
'?'
,
default
=
10
)
parser_input_file
.
add_argument
(
'--start_prop'
,
nargs
=
'?'
,
default
=
None
)
parser_input_file
.
add_argument
(
'--inv_prop'
,
nargs
=
'?'
,
default
=
None
)
parser_input_file
.
add_argument
(
'--output'
,
nargs
=
'?'
,
default
=
'result/'
)
parser_input_file
.
add_argument
(
'--output'
,
action
=
readable_dir
,
nargs
=
'?'
,
default
=
'result/'
)
parser_input_file
.
set_defaults
(
func
=
compute_macs
)
...
...
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