duckypad-twitch/duckypad_twitch/configuration.py

21 lines
430 B
Python
Raw Normal View History

2023-07-05 13:44:21 +01:00
from pathlib import Path
try:
import tomllib
except ModuleNotFoundError:
import tomli as tomllib # type: ignore
configuration = {}
configpath = Path.cwd() / 'configs' / 'duckypad.toml'
2023-07-05 13:44:21 +01:00
if not configpath.exists():
raise OSError(f'unable to locate {configpath}')
2023-07-05 13:44:21 +01:00
with open(configpath, 'rb') as f:
2023-07-05 13:44:21 +01:00
configuration = tomllib.load(f)
def get(name):
if name in configuration:
return configuration[name]