Skip to content
Snippets Groups Projects
Commit 1fb4bd43 authored by David Schäfer's avatar David Schäfer
Browse files

False as the default plot configuration value if the field is missing.

Fixes #17
parent fb3e8f05
No related branches found
No related tags found
No related merge requests found
......@@ -24,7 +24,7 @@ CONFIG_TYPES = {
F.START: pd.to_datetime,
F.END: pd.to_datetime,
F.TESTS: str,
F.PLOT: lambda v: str(v).lower() != "false",
F.PLOT: lambda v: str(v).lower() == "true",
F.LINENUMBER: int,
}
......@@ -60,11 +60,19 @@ def _castRow(row: Dict[str, str]) -> Dict[str, Any]:
cast values to the data type given in 'types'
"""
out = {}
for k, v in row.items():
keys = pd.Index(row.keys())
for k, func in CONFIG_TYPES.items():
try:
out[k] = CONFIG_TYPES[k](v)
except:
_raise(row, ValueError, f"invalid value: v")
key = keys[keys.str.match(k)][0]
except IndexError:
continue
value = row[key]
# NOTE:
# this check and the raise should be moved to checkConfig
try:
out[key] = func(value)
except ValueError:
_raise(row, ValueError, f"invalid value: '{value}'")
return out
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment