From 8476fd6a35c6a9a0db50a40b5187af8069224abf Mon Sep 17 00:00:00 2001 From: Erik Johnson Date: Thu, 16 Dec 2021 09:46:12 -0600 Subject: [PATCH] i3pystatus.scores.nba: Fix spurious log warning for games that haven't started (#827) --- i3pystatus/scores/nba.py | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/i3pystatus/scores/nba.py b/i3pystatus/scores/nba.py index a7757e7..5aa4d4a 100644 --- a/i3pystatus/scores/nba.py +++ b/i3pystatus/scores/nba.py @@ -232,19 +232,20 @@ class NBA(ScoresBackend): ret['quarter'] = '' clock = game.get('gameClock', '') - try: - mins, secs = re.match(r'^PT(\d+)M(\d+\.\d)0?S$', clock).groups() - except AttributeError: - ret['time_remaining'] = '' - self.logger.warning('Failed to parse gameClock value: {clock}') - else: - mins = mins.lstrip('0') - if mins: - secs = secs.split('.')[0] - if not mins and secs == '00.0': - ret['time_remaining'] = 'End' + ret['time_remaining'] = '' + if clock: + try: + mins, secs = re.match(r'^PT(\d+)M(\d+\.\d)0?S$', clock).groups() + except AttributeError: + self.logger.warning(f'Failed to parse gameClock value: {clock}') else: - ret['time_remaining'] = f'{mins}:{secs}' + mins = mins.lstrip('0') + if mins: + secs = secs.split('.')[0] + if not mins and secs == '00.0': + ret['time_remaining'] = 'End' + else: + ret['time_remaining'] = f'{mins}:{secs}' ret['overtime'] = ret['quarter'] if 'OT' in ret['quarter'] else ''