Allow comments and trailing commas in remotepairlist files

closes #8971
This commit is contained in:
Matthias
2023-07-27 18:02:49 +02:00
parent 8f18a52cdf
commit 9a400d0e6f
2 changed files with 4 additions and 3 deletions

View File

@@ -3,15 +3,16 @@ Remote PairList provider
Provides pair list fetched from a remote source Provides pair list fetched from a remote source
""" """
import json
import logging import logging
from pathlib import Path from pathlib import Path
from typing import Any, Dict, List, Tuple from typing import Any, Dict, List, Tuple
import rapidjson
import requests import requests
from cachetools import TTLCache from cachetools import TTLCache
from freqtrade import __version__ from freqtrade import __version__
from freqtrade.configuration.load_config import CONFIG_PARSE_MODE
from freqtrade.constants import Config from freqtrade.constants import Config
from freqtrade.exceptions import OperationalException from freqtrade.exceptions import OperationalException
from freqtrade.exchange.types import Tickers from freqtrade.exchange.types import Tickers
@@ -236,7 +237,7 @@ class RemotePairList(IPairList):
if file_path.exists(): if file_path.exists():
with file_path.open() as json_file: with file_path.open() as json_file:
# Load the JSON data into a dictionary # Load the JSON data into a dictionary
jsonparse = json.load(json_file) jsonparse = rapidjson.load(json_file, parse_mode=CONFIG_PARSE_MODE)
try: try:
pairlist = self.process_json(jsonparse) pairlist = self.process_json(jsonparse)

View File

@@ -35,7 +35,7 @@ def test_gen_pairlist_with_local_file(mocker, rpl_config):
mock_file_path.exists.return_value = True mock_file_path.exists.return_value = True
jsonparse = json.loads(mock_file.read.return_value) jsonparse = json.loads(mock_file.read.return_value)
mocker.patch('freqtrade.plugins.pairlist.RemotePairList.json.load', return_value=jsonparse) mocker.patch('freqtrade.plugins.pairlist.RemotePairList.rapidjson.load', return_value=jsonparse)
rpl_config['pairlists'] = [ rpl_config['pairlists'] = [
{ {