mirror of
https://github.com/ManiMatter/decluttarr.git
synced 2026-04-17 21:53:58 +02:00
Support environment variables in config file
Signed-off-by: Matt Provost <mattprovost6@gmail.com>
This commit is contained in:
@@ -9,7 +9,7 @@ black==24.8.0
|
||||
pylint==3.3.3
|
||||
autoflake==2.3.1
|
||||
isort==5.13.2
|
||||
envyaml==1.10.211231
|
||||
pyyaml_env_tag==1.1
|
||||
demjson3==3.0.6
|
||||
ruff==0.11.11
|
||||
watchdog==6.0.0
|
||||
watchdog==6.0.0
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
import os
|
||||
from pathlib import Path
|
||||
import yaml
|
||||
from yaml_env_tag import add_env_tag
|
||||
|
||||
from src.utils.log_setup import logger
|
||||
|
||||
LOADER = add_env_tag(yaml.Loader)
|
||||
|
||||
CONFIG_MAPPING = {
|
||||
"general": [
|
||||
"LOG_LEVEL",
|
||||
@@ -82,7 +85,7 @@ def _load_from_env() -> dict:
|
||||
continue
|
||||
|
||||
try:
|
||||
parsed_value = yaml.safe_load(raw_value)
|
||||
parsed_value = yaml.load(raw_value, Loader=LOADER)
|
||||
parsed_value = _lowercase(parsed_value)
|
||||
except yaml.YAMLError as e:
|
||||
logger.error(
|
||||
@@ -116,7 +119,7 @@ def _load_from_yaml_file(settings):
|
||||
config_path = settings.paths.config_file
|
||||
try:
|
||||
with Path(config_path).open(encoding="utf-8") as file:
|
||||
return yaml.safe_load(file) or {}
|
||||
return yaml.load(file, Loader=LOADER) or {}
|
||||
except yaml.YAMLError as e:
|
||||
logger.error("Error reading YAML file: %s", e)
|
||||
return {}
|
||||
|
||||
Reference in New Issue
Block a user