Skip to content

Commit

Permalink
adds tomllib compatibility layer
Browse files Browse the repository at this point in the history
lazy loads the module
  • Loading branch information
onyx-and-iris committed Jul 5, 2023
1 parent 2ad4aa8 commit ffc5b38
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions slobs_websocket/streamlabs_obs.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import time
from pathlib import Path

import tomli
import websocket

from . import exceptions
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit ffc5b38

Please sign in to comment.