Create the 'secrets' folder if it doesn't exist on first run

Easier setup for users
This commit is contained in:
Patrick Robertson
2025-03-17 09:40:46 +00:00
parent d59530c8e7
commit 7badf89c28

View File

@@ -8,6 +8,7 @@ flexible setup in various environments.
import argparse
from ruamel.yaml import YAML, CommentedMap
import json
import os
from loguru import logger
@@ -230,6 +231,10 @@ def read_yaml(yaml_filename: str) -> CommentedMap:
def store_yaml(config: CommentedMap, yaml_filename: str) -> None:
config_to_save = deepcopy(config)
## if the save path is the default location (secrets) then create the 'secrets' folder
if os.path.dirname(yaml_filename) == "secrets":
os.makedirs("secrets", exist_ok=True)
auth_dict = config_to_save.get("authentication", {})
if auth_dict and auth_dict.get("load_from_file"):
# remove all other values from the config, don't want to store it in the config file