From ffc5b38746b28e0ac245054fefc296e594c2cf6a Mon Sep 17 00:00:00 2001 From: onyx-and-iris Date: Wed, 5 Jul 2023 04:35:30 +0100 Subject: [PATCH] adds tomllib compatibility layer lazy loads the module --- slobs_websocket/streamlabs_obs.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/slobs_websocket/streamlabs_obs.py b/slobs_websocket/streamlabs_obs.py index 4ffc97e..0799f37 100644 --- a/slobs_websocket/streamlabs_obs.py +++ b/slobs_websocket/streamlabs_obs.py @@ -9,7 +9,6 @@ import time from pathlib import Path -import tomli import websocket from . import exceptions @@ -110,10 +109,15 @@ def __init__( self.StreamingService = StreamingService() def _conn_from_toml(self): + try: + import tomllib + except ModuleNotFoundError: + import tomli as tomllib + filepath = Path.cwd() / "config.toml" if filepath.is_file(): with open(filepath, "rb") as f: - conn = tomli.load(f) + conn = tomllib.load(f) return conn["connection"] def __enter__(self):