stable/freqtrade/configuration/load_config.py

31 lines
776 B
Python
Raw Normal View History

2019-08-10 12:15:09 +00:00
"""
This module contain functions to load the configuration file
"""
import json
import logging
import sys
from typing import Any, Dict
from freqtrade import OperationalException
logger = logging.getLogger(__name__)
def load_config_file(path: str) -> Dict[str, Any]:
"""
Loads a config file from the given path
:param path: path as str
:return: configuration as dictionary
"""
try:
# Read config from stdin if requested in the options
with open(path) if path != '-' else sys.stdin as file:
config = json.load(file)
except FileNotFoundError:
raise OperationalException(
f'Config file "{path}" not found!'
' Please create a config file or check whether it exists.')
return config