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
tomotools
Nabu
Commits
1bb75bdf
Commit
1bb75bdf
authored
Nov 19, 2019
by
Pierre Paleo
Browse files
Add validator CLI took
parent
e182a53f
Changes
4
Hide whitespace changes
Inline
Side-by-side
nabu/resources/cli/validate.py
View file @
1bb75bdf
...
...
@@ -43,11 +43,20 @@ def nabu_validate(fname):
validator
.
remove_unused_radios
()
if
__name__
==
"__main__"
:
def
main
():
args
=
parse_params_values
(
ValidateConfig
,
parser_description
=
"Validate a Nabu configuration file."
)
fname
=
args
[
"input_file"
]
nabu_validate
(
fname
)
try
:
nabu_validate
(
fname
)
except
Exception
as
exc
:
print
(
"Error while checking %s:"
%
fname
)
print
(
exc
)
exit
(
-
1
)
print
(
"Configuration file %s is valid"
%
fname
)
if
__name__
==
"__main__"
:
main
()
nabu/resources/nabu_config.py
View file @
1bb75bdf
...
...
@@ -14,7 +14,7 @@ nabu_config = {
"default"
:
"/path/to/my/dataset"
,
"help"
:
"Dataset folder location"
,
"hst_key"
:
None
,
"validator"
:
d
irectory
_location_validator
,
"validator"
:
d
ataset
_location_validator
,
},
"file_prefix"
:
{
"default"
:
"my_dataset_"
,
...
...
@@ -105,10 +105,10 @@ nabu_config = {
"validator"
:
float_validator
,
},
"paganin_lmicron"
:
{
"default"
:
"
1
"
,
"default"
:
""
,
"help"
:
"Alternatively to delta/beta, the parameter 'Lmicron' of PyHST can be specified.
\n
L^2 = pi * wavelength * distance * delta/beta"
,
"hst_key"
:
"paganin_lmicron"
,
"validator"
:
float_validator
,
"validator"
:
optional_
float_validator
,
},
"paganin_marge"
:
{
"default"
:
"50"
,
...
...
@@ -174,12 +174,12 @@ nabu_config = {
},
"padding_type"
:
{
"default"
:
"zeros"
,
"help"
:
"Padding type for FBP. Available are: zeros, edge
, mirror
"
,
"help"
:
"Padding type for FBP. Available are: zeros, edge"
,
"hst_key"
:
None
,
"validator"
:
padding_mode_validator
,
},
"enable_halftomo"
:
{
"default"
:
"
1
"
,
"default"
:
"
0
"
,
"help"
:
"
\n
Parameters related to half-acquisition tomography
\n
-------------------------------------------------
\n
Whether to enable half-acquisition"
,
"hst_key"
:
None
,
"validator"
:
boolean_validator
,
...
...
nabu/resources/validators.py
View file @
1bb75bdf
...
...
@@ -111,6 +111,13 @@ def directory_location_validator(location):
assert
path
.
isdir
(
location
),
"location must be a directory"
return
location
@
validator
def
dataset_location_validator
(
location
):
if
not
(
path
.
isdir
(
location
)):
assert
path
.
isfile
(
location
)
and
path
.
splitext
(
location
)[
-
1
]
in
[
".h5"
,
".hdf5"
],
"Dataset location must be a directory or a HDF5 file"
return
location
@
validator
def
directory_writeable_validator
(
location
):
assert
os
.
access
(
location
,
os
.
W_OK
),
"Directory must be writeable"
...
...
setup.py
View file @
1bb75bdf
...
...
@@ -108,6 +108,7 @@ def setup_package():
'console_scripts'
:
[
"nabu-test=nabu.tests:nabu_test"
,
"nabu-config=nabu.resources.cli.bootstrap:bootstrap"
,
"nabu-validate=nabu.resources.cli.validate:main"
,
],
},
...
...
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