lib: strip values for timedelta from string

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2021-12-23 18:49:35 +01:00
parent ca0250e19f
commit e7e0e6d213

View file

@ -34,7 +34,7 @@ def timedelta_from_string(expr: str) -> datetime.timedelta:
key, value = duration_pair.split("=") key, value = duration_pair.split("=")
if key.lower() not in ALLOWED_KEYS: if key.lower() not in ALLOWED_KEYS:
continue continue
kwargs[key.lower()] = float(value) kwargs[key.lower()] = float(value.strip())
if len(kwargs) < 1: if len(kwargs) < 1:
raise ValueError("No valid keys to pass to timedelta") raise ValueError("No valid keys to pass to timedelta")
return datetime.timedelta(**kwargs) return datetime.timedelta(**kwargs)