1
0
mirror of https://github.com/natekspencer/hacs-oasis_mini.git synced 2025-11-15 08:33:52 -05:00

Better error handling

This commit is contained in:
Nathan Spencer
2024-08-03 17:31:30 -06:00
parent a44c035828
commit 33e62528ba
9 changed files with 1978 additions and 828 deletions

View File

@@ -4,8 +4,13 @@ from __future__ import annotations
import json
import os
from typing import Final
from typing import Any, Final
__TRACKS_FILE = os.path.join(os.path.dirname(__file__), "tracks.json")
with open(__TRACKS_FILE, "r", encoding="utf8") as file:
TRACKS: Final[dict[str, dict[str, str]]] = json.load(file)
try:
with open(__TRACKS_FILE, "r", encoding="utf8") as file:
TRACKS: Final[dict[int, dict[str, Any]]] = {
int(k): v for k, v in json.load(file).items()
}
except Exception: # ignore: broad-except
TRACKS = {}