combine normalize method and config validation to in_files

This commit is contained in:
Matthias 2019-08-10 19:58:04 +02:00
parent afba31c3f9
commit eb328037b7

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, List
from typing import Any, Callable, Dict, List, Optional
from freqtrade import OperationalException, constants
from freqtrade.configuration.check_exchange import check_exchange
@ -59,16 +59,16 @@ class Configuration(object):
# Merge config options, overwriting old values
config = deep_merge_dicts(load_config_file(path), config)
return config
def _normalize_config(self, config: Dict[str, Any]) -> None:
"""
Make config more canonical -- i.e. for example add missing parts that we expect
to be normally in it...
"""
# Normalize config
if 'internals' not in config:
config['internals'] = {}
# validate configuration before returning
logger.info('Validating configuration ...')
validate_config_schema(config)
return config
def load_config(self) -> Dict[str, Any]:
"""
Extract information for sys.argv and load the bot configuration
@ -77,12 +77,6 @@ class Configuration(object):
# Load all configs
config: Dict[str, Any] = Configuration.from_files(self.args.config)
# Make resulting config more canonical
self._normalize_config(config)
logger.info('Validating configuration ...')
validate_config_schema(config)
self._validate_config_consistency(config)
self._process_common_options(config)