change method from _load_config_Files to from_files()

This commit is contained in:
Matthias 2019-08-10 19:57:49 +02:00
parent c4cbe79b48
commit afba31c3f9
1 changed files with 13 additions and 7 deletions

View File

@ -4,7 +4,7 @@ This module contains the configuration class
import logging
import warnings
from argparse import Namespace
from typing import Any, Callable, Dict, Optional
from typing import Any, Callable, Dict, Optional, List
from freqtrade import OperationalException, constants
from freqtrade.configuration.check_exchange import check_exchange
@ -39,16 +39,22 @@ class Configuration(object):
return self.config
def _load_config_files(self) -> Dict[str, Any]:
@staticmethod
def from_files(files: List[str]) -> Dict[str, Any]:
"""
Iterate through the config files passed in the args,
loading all of them and merging their contents.
Iterate through the config files passed in, loading all of them
and merging their contents.
Files are loaded in sequence, parameters in later configuration files
override the same parameter from an earlier file (last definition wins).
:param files: List of file paths
:return: configuration dictionary
"""
# Keep this method as staticmethod, so it can be used from interactive environments
config: Dict[str, Any] = {}
# We expect here a list of config filenames
for path in self.args.config:
logger.info('Using config: %s ...', path)
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)
@ -69,7 +75,7 @@ class Configuration(object):
:return: Configuration dictionary
"""
# Load all configs
config: Dict[str, Any] = self._load_config_files()
config: Dict[str, Any] = Configuration.from_files(self.args.config)
# Make resulting config more canonical
self._normalize_config(config)