File tree Expand file tree Collapse file tree 2 files changed +9
-2
lines changed
resotocore/resotocore/infra_apps Expand file tree Collapse file tree 2 files changed +9
-2
lines changed Original file line number Diff line number Diff line change 10
10
from aiostream .core import Stream
11
11
from aiostream import stream
12
12
from argparse import Namespace
13
- from resotolib .durations import parse_duration
13
+ from resotolib .durations import parse_optional_duration
14
14
from resotolib .asynchronous .utils import async_lines
15
15
16
16
@@ -72,7 +72,7 @@ async def perform_search(search: str) -> AsyncIterator[Json]:
72
72
async for result in ctx :
73
73
yield result
74
74
75
- template .globals ["parse_duration" ] = parse_duration
75
+ template .globals ["parse_duration" ] = parse_optional_duration
76
76
template .globals ["search" ] = perform_search
77
77
78
78
async for line in async_lines (template .generate_async (config = config , args = kwargs , stdin = stdin )):
Original file line number Diff line number Diff line change @@ -56,6 +56,13 @@ def parse_duration(ds: str) -> timedelta:
56
56
return timedelta (seconds = duration_parser .parse (ds ))
57
57
58
58
59
+ def parse_optional_duration (ds : str ) -> Optional [timedelta ]:
60
+ try :
61
+ return parse_duration (ds )
62
+ except Exception :
63
+ return None
64
+
65
+
59
66
def duration_str (duration : timedelta , precision : Optional [int ] = 0 , down_to_unit : Optional [str ] = None ) -> str :
60
67
"""
61
68
Convert a timedelta to a string representing the duration human-readable short unit syntax.
You can’t perform that action at this time.
0 commit comments