kanidm/pykanidm/kanidm/utils.py
James Hodgkinson 805ac2dd16
Python module and rewritten RADIUS integration (#826)
* added python kanidm module
* rewrote RADIUS integration
* updated the documentation
* updating github actions to run more often
* BLEEP BLOOP ASYNCIO IS GR8
* adding config to makefile to run pykanidm tests

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Firstyear <william@blackhats.net.au>
2022-06-20 20:16:55 +10:00

22 lines
641 B
Python

""" utility functions """
from pathlib import Path
from typing import Any, Dict, Union
import toml
def load_config(filename: Union[str, Path] = "/etc/kanidm/config") -> Dict[str, Any]:
"""loads the configuration file"""
if isinstance(filename, Path):
config_filepath = filename
else:
config_filepath = Path(filename).expanduser().resolve()
if not config_filepath.exists():
raise FileNotFoundError(
f"Failed to find configuration file ({config_filepath}), quitting!",
)
config_data: Dict[str, Any] = toml.load(config_filepath.open(encoding="utf-8"))
return config_data