extract load_from_files to load_config

This commit is contained in:
Matthias
2022-04-07 20:13:52 +02:00
parent 673b3034ee
commit 1347107c1e
4 changed files with 29 additions and 25 deletions

View File

@@ -4,12 +4,15 @@ This module contain functions to load the configuration file
import logging
import re
import sys
from copy import deepcopy
from pathlib import Path
from typing import Any, Dict
from typing import Any, Dict, List
import rapidjson
from freqtrade.constants import MINIMAL_CONFIG
from freqtrade.exceptions import OperationalException
from freqtrade.misc import deep_merge_dicts
logger = logging.getLogger(__name__)
@@ -70,3 +73,21 @@ def load_config_file(path: str) -> Dict[str, Any]:
)
return config
def load_from_files(files: List[str]) -> Dict[str, Any]:
config: Dict[str, Any] = {}
if not files:
return deepcopy(MINIMAL_CONFIG)
# We expect here a list of config filenames
for path in files:
logger.info(f'Using config: {path} ...')
# Merge config options, overwriting old values
config = deep_merge_dicts(load_config_file(path), config)
config['config_files'] = files
return config