#2533: added tests + log level for output

This commit is contained in:
Czar Echavez
2024-04-30 15:43:25 +01:00
parent c94fa653f7
commit 59990813f5
8 changed files with 294 additions and 58 deletions

View File

@@ -1,17 +1,30 @@
from typing import Dict
from pathlib import Path
from typing import Dict, Optional
import yaml
from primaite import PRIMAITE_PATHS
def get_primaite_config_dict() -> Dict:
"""Returns a dict containing the PrimAITE application config."""
if PRIMAITE_PATHS.app_config_file_path.exists():
with open(PRIMAITE_PATHS.app_config_file_path, "r") as file:
def get_primaite_config_dict(
config_path: Optional[Path] = None
) -> Dict:
"""
Returns a dict containing the PrimAITE application config.
:param: config_path: takes in a path object - leave empty to use the default app config path
"""
err_msg = "PrimAITE application config could not be loaded."
if config_path is None:
config_path = PRIMAITE_PATHS.app_config_file_path
err_msg = "PrimAITE application config was not found. Have you run `primaite setup`?"
if config_path.exists():
with open(config_path, "r") as file:
return yaml.safe_load(file)
else:
print("PrimAITE application config was not found. Have you run [bold red]primaite setup[/bold red]?")
print(err_msg)
def is_dev_mode() -> bool: