mirror of
https://github.com/kanidm/kanidm.git
synced 2025-02-24 04:57:00 +01:00
* 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>
22 lines
641 B
Python
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
|