Commit c39ef4a6 authored by Pierre Paleo's avatar Pierre Paleo
Browse files

nabu CLI: Fix single scalar user indice

parent 877af696
......@@ -5,6 +5,7 @@ from ...io.config import NabuConfigParser, validate_nabu_config
from .utils import parse_params_values
from ..utils import is_hdf5_extension
from .cli_configs import ReconstructConfig
from ..validators import convert_to_int
def update_reconstruction_start_end(conf_dict, user_indices):
......@@ -12,24 +13,30 @@ def update_reconstruction_start_end(conf_dict, user_indices):
return
rec_cfg = conf_dict["reconstruction"]
err = None
if user_indices in ["first", "middle", "last"]:
val_int, conv_err = convert_to_int(user_indices)
if conv_err is None:
start_z = user_indices
end_z = user_indices
elif user_indices == "all":
start_z = 0
end_z = -1
elif "-" in user_indices:
try:
start_z, end_z = user_indices.split("-")
start_z = int(start_z)
end_z = int(end_z)
except Exception as exc:
err = "Could not interpret slice indices '%s': %s" % (user_indices, str(exc))
else:
err = "Could not interpret slice indices: %s" % user_indices
if err is not None:
print(err)
exit(1)
if user_indices in ["first", "middle", "last"]:
start_z = user_indices
end_z = user_indices
elif user_indices == "all":
start_z = 0
end_z = -1
elif "-" in user_indices:
try:
start_z, end_z = user_indices.split("-")
start_z = int(start_z)
end_z = int(end_z)
except Exception as exc:
err = "Could not interpret slice indices '%s': %s" % (user_indices, str(exc))
else:
err = "Could not interpret slice indices: %s" % user_indices
if err is not None:
print(err)
exit(1)
rec_cfg["start_z"] = start_z
rec_cfg["end_z"] = end_z
......
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