mirror of
https://github.com/sigmasternchen/grimoire
synced 2025-03-15 16:18:55 +00:00
36 lines
806 B
Python
36 lines
806 B
Python
|
import yaml
|
||
|
from yaml import Loader
|
||
|
|
||
|
from grimoiressg.modules import available_modules
|
||
|
|
||
|
|
||
|
def default_config():
|
||
|
return {
|
||
|
"enabled_modules": [
|
||
|
"tags",
|
||
|
"markdown",
|
||
|
"templating"
|
||
|
]
|
||
|
}
|
||
|
|
||
|
|
||
|
def read_config(context):
|
||
|
config_file = context.get("config_file", None)
|
||
|
|
||
|
if not config_file:
|
||
|
print("No config file given; using default config")
|
||
|
config = default_config()
|
||
|
else:
|
||
|
with open(config_file, "r") as file:
|
||
|
config = yaml.load(file, Loader) or {}
|
||
|
|
||
|
print("Enabled modules:")
|
||
|
for module in config.get("enabled_modules", []):
|
||
|
print(f" - {module}")
|
||
|
if module not in available_modules:
|
||
|
print(f" ERROR: Module does not exist")
|
||
|
exit(1)
|
||
|
print()
|
||
|
|
||
|
return config
|