From 2d60e4b18b2c982c88578cdd6ff81f0c6b993396 Mon Sep 17 00:00:00 2001 From: hroff-1902 Date: Mon, 12 Aug 2019 00:32:03 +0300 Subject: [PATCH] allow comments and trailing commas in config files --- freqtrade/configuration/load_config.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/freqtrade/configuration/load_config.py b/freqtrade/configuration/load_config.py index 25504144f..7a3ca1798 100644 --- a/freqtrade/configuration/load_config.py +++ b/freqtrade/configuration/load_config.py @@ -1,7 +1,7 @@ """ This module contain functions to load the configuration file """ -import json +import rapidjson import logging import sys from typing import Any, Dict @@ -12,6 +12,9 @@ from freqtrade import OperationalException logger = logging.getLogger(__name__) +CONFIG_PARSE_MODE = rapidjson.PM_COMMENTS | rapidjson.PM_TRAILING_COMMAS + + def load_config_file(path: str) -> Dict[str, Any]: """ Loads a config file from the given path @@ -21,7 +24,7 @@ def load_config_file(path: str) -> Dict[str, Any]: try: # Read config from stdin if requested in the options with open(path) if path != '-' else sys.stdin as file: - config = json.load(file) + config = rapidjson.load(file, parse_mode=CONFIG_PARSE_MODE) except FileNotFoundError: raise OperationalException( f'Config file "{path}" not found!'