lib: strip values for timedelta from string
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
parent
ca0250e19f
commit
e7e0e6d213
|
@ -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)
|
||||||
|
|
Reference in a new issue