From 0e12f8f1857c05fefbfe6f11fce02013ae20e941 Mon Sep 17 00:00:00 2001 From: Ivan Usov Date: Fri, 11 Sep 2020 12:12:27 +0200 Subject: [PATCH] Stop in case of malformed metadata section Remove exception hadling because if there is an error in reading, we shouldn't return partially read data, which will cause issues later. --- pyzebra/load_1D.py | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/pyzebra/load_1D.py b/pyzebra/load_1D.py index d2d6e01..e3aaf05 100644 --- a/pyzebra/load_1D.py +++ b/pyzebra/load_1D.py @@ -72,19 +72,12 @@ def load_1D(filepath): if "=" in line: variable, value = line.split("=") variable = variable.strip() - try: - if variable in META_VARS_FLOAT: - det_variables["meta"][variable] = float(value) - elif variable in META_VARS_STR: - det_variables["meta"][variable] = str(value)[:-1].strip() - elif variable in META_UB_MATRIX: - det_variables["meta"][variable] = re.findall( - r"[-+]?\d*\.\d+|\d+", str(value) - ) - except ValueError as error: - print( - "Some values are not in expected format (str or float), error:", str(error) - ) + if variable in META_VARS_FLOAT: + det_variables["meta"][variable] = float(value) + elif variable in META_VARS_STR: + det_variables["meta"][variable] = str(value)[:-1].strip() + elif variable in META_UB_MATRIX: + det_variables["meta"][variable] = re.findall(r"[-+]?\d*\.\d+|\d+", str(value)) elif "#data" in line: if det_variables["file_type"] == "ccl":