diff --git a/obsws_python/baseclient.py b/obsws_python/baseclient.py index 4b8ba2f..9f43704 100644 --- a/obsws_python/baseclient.py +++ b/obsws_python/baseclient.py @@ -6,9 +6,13 @@ from pathlib import Path from random import randint try: - import tomllib + try: + import tomllib + except ModuleNotFoundError: + import tomli as tomllib except ModuleNotFoundError: - import tomli as tomllib + # ObsClient(host='...', port='...', password='...') must be used + tomllib = None import websocket @@ -21,7 +25,12 @@ class ObsClient: def __init__(self, **kwargs): defaultkwargs = {"host": "localhost", "port": 4455, "password": None, "subs": 0} if not any(key in kwargs for key in ("host", "port", "password")): - kwargs |= self._conn_from_toml() + if tomllib: + kwargs |= self._conn_from_toml() + else: + raise ModuleNotFoundError( + "tomllib not installed; Perhaps use " + "ObsClient(host='...', port='...', password='...')") kwargs = defaultkwargs | kwargs for attr, val in kwargs.items(): setattr(self, attr, val)