From cd4c3d379a6f8f95db0f07503bd3d9fbfc5dc086 Mon Sep 17 00:00:00 2001 From: Oscar Krause Date: Wed, 16 Apr 2025 15:01:14 +0200 Subject: [PATCH] code styling --- app/util.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/app/util.py b/app/util.py index a9e9b58..66df77e 100644 --- a/app/util.py +++ b/app/util.py @@ -1,5 +1,4 @@ import logging -from json import load as json_load from datetime import datetime, UTC, timedelta from json import loads as json_loads from os.path import join, dirname, isfile @@ -338,9 +337,8 @@ class DriverMatrix: def __load(self): try: - file = open(DriverMatrix.__DRIVER_MATRIX_FILENAME) - DriverMatrix.__DRIVER_MATRIX = json_load(file) - file.close() + with open(DriverMatrix.__DRIVER_MATRIX_FILENAME, 'r') as f: + DriverMatrix.__DRIVER_MATRIX = json_loads(f.read()) self.log.debug(f'Successfully loaded "{DriverMatrix.__DRIVER_MATRIX_FILENAME}".') except Exception as e: DriverMatrix.__DRIVER_MATRIX = {} # init empty dict to not try open file everytime, just when restarting app