#2533: added tests + log level for output
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user