From a9dc54bebc943000252975ef25ddcb51681fc284 Mon Sep 17 00:00:00 2001 From: Alexandre Flament Date: Mon, 5 Oct 2020 13:50:33 +0200 Subject: [mod] Add searx.data module Instead of loading the data/*.json in different location, load these files in the new searx.data module. --- searx/engines/__init__.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'searx/engines/__init__.py') diff --git a/searx/engines/__init__.py b/searx/engines/__init__.py index 5b91c08ce..9cdca47b7 100644 --- a/searx/engines/__init__.py +++ b/searx/engines/__init__.py @@ -19,13 +19,12 @@ along with searx. If not, see < http://www.gnu.org/licenses/ >. import sys import threading from os.path import realpath, dirname -from io import open from babel.localedata import locale_identifiers from flask_babel import gettext from operator import itemgetter -from json import loads from searx import settings from searx import logger +from searx.data import ENGINES_LANGUAGES from searx.poolrequests import get from searx.utils import load_module, match_language, get_engine_from_settings @@ -38,7 +37,6 @@ engines = {} categories = {'general': []} -languages = loads(open(engine_dir + '/../data/engines_languages.json', 'r', encoding='utf-8').read()) babel_langs = [lang_parts[0] + '-' + lang_parts[-1] if len(lang_parts) > 1 else lang_parts[0] for lang_parts in (lang_code.split('_') for lang_code in locale_identifiers())] @@ -108,8 +106,8 @@ def load_engine(engine_data): sys.exit(1) # assign supported languages from json file - if engine_data['name'] in languages: - setattr(engine, 'supported_languages', languages[engine_data['name']]) + if engine_data['name'] in ENGINES_LANGUAGES: + setattr(engine, 'supported_languages', ENGINES_LANGUAGES[engine_data['name']]) # find custom aliases for non standard language codes if hasattr(engine, 'supported_languages'): -- cgit v1.2.3