From 036f8886d2c8ec1d246d1f06db7872b2e4288320 Mon Sep 17 00:00:00 2001 From: David C Ellis Date: Wed, 18 Nov 2026 18:36:28 +0000 Subject: [PATCH] Handle the empty string case when converting to int and time. --- src/splitguides/livesplit_client/__init__.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/splitguides/livesplit_client/__init__.py b/src/splitguides/livesplit_client/__init__.py index 55c54ac..d03badb 100644 --- a/src/splitguides/livesplit_client/__init__.py +++ b/src/splitguides/livesplit_client/__init__.py @@ -32,6 +32,10 @@ def parse_time(time_str: str) -> timedelta: :param time_str: :return: """ + if time_str == "": + # If there is no str, return a timedelta of 0 + return timedelta() + match = pattern.match(time_str) if match is None: raise RuntimeError("String time from livesplit did not match expected pattern") @@ -145,7 +149,10 @@ def receive(self, datatype="text"): if datatype == "time": result = parse_time(result) elif datatype == "int": - return int(result) + try: + return int(result) + except ValueError: + return 0 return result