change method from _load_config_Files to from_files()
This commit is contained in:
parent
c4cbe79b48
commit
afba31c3f9
@ -4,7 +4,7 @@ This module contains the configuration class
|
|||||||
import logging
|
import logging
|
||||||
import warnings
|
import warnings
|
||||||
from argparse import Namespace
|
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 import OperationalException, constants
|
||||||
from freqtrade.configuration.check_exchange import check_exchange
|
from freqtrade.configuration.check_exchange import check_exchange
|
||||||
@ -39,16 +39,22 @@ class Configuration(object):
|
|||||||
|
|
||||||
return self.config
|
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,
|
Iterate through the config files passed in, loading all of them
|
||||||
loading all of them and merging their contents.
|
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] = {}
|
config: Dict[str, Any] = {}
|
||||||
|
|
||||||
# We expect here a list of config filenames
|
# We expect here a list of config filenames
|
||||||
for path in self.args.config:
|
for path in files:
|
||||||
logger.info('Using config: %s ...', path)
|
logger.info(f'Using config: {path} ...')
|
||||||
|
|
||||||
# Merge config options, overwriting old values
|
# Merge config options, overwriting old values
|
||||||
config = deep_merge_dicts(load_config_file(path), config)
|
config = deep_merge_dicts(load_config_file(path), config)
|
||||||
@ -69,7 +75,7 @@ class Configuration(object):
|
|||||||
:return: Configuration dictionary
|
:return: Configuration dictionary
|
||||||
"""
|
"""
|
||||||
# Load all configs
|
# 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
|
# Make resulting config more canonical
|
||||||
self._normalize_config(config)
|
self._normalize_config(config)
|
||||||
|
Loading…
Reference in New Issue
Block a user