Merge pull request #17 from kamalmostafa/no-tomllib

allow use without installing tomllib
This commit is contained in:
Onyx and Iris 2022-12-04 19:37:25 +00:00 committed by GitHub
commit 335fa42948
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -5,11 +5,6 @@ import logging
from pathlib import Path from pathlib import Path
from random import randint from random import randint
try:
import tomllib
except ModuleNotFoundError:
import tomli as tomllib
import websocket import websocket
from .error import OBSSDKError from .error import OBSSDKError
@ -37,6 +32,10 @@ class ObsClient:
self.server_hello = json.loads(self.ws.recv()) self.server_hello = json.loads(self.ws.recv())
def _conn_from_toml(self) -> dict: def _conn_from_toml(self) -> dict:
try:
import tomllib
except ModuleNotFoundError:
import tomli as tomllib
conn = {} conn = {}
filepath = Path.cwd() / "config.toml" filepath = Path.cwd() / "config.toml"
if filepath.exists(): if filepath.exists():