Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2cc736bd authored by Nicolas Gelot's avatar Nicolas Gelot
Browse files

Fix python -X dev warnings

parent 6e676cc0
Loading
Loading
Loading
Loading
+7 −3
Original line number Diff line number Diff line
@@ -18,8 +18,8 @@ along with searx. If not, see < http://www.gnu.org/licenses/ >.
import logging
from os import environ
from os.path import realpath, dirname, join, abspath, isfile
from io import open
from yaml import load

import yaml

searx_dir = abspath(dirname(__file__))
engine_dir = dirname(realpath(__file__))
@@ -46,7 +46,11 @@ if not settings_path:

# load settings
with open(settings_path, 'r', encoding='utf-8') as settings_yaml:
    settings = load(settings_yaml)
    # XXX: docker-compose does not support yet yaml >= 5
    if int(yaml.__version__.split('.')[0]) >= 5:
        settings = yaml.load(settings_yaml, Loader=yaml.FullLoader)
    else:
        settings = yaml.load(settings_yaml)

'''
enable debug if
+5 −5
Original line number Diff line number Diff line
@@ -18,12 +18,11 @@ 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
import json
from pathlib import Path
from babel.localedata import locale_identifiers
from flask_babel import gettext
from operator import itemgetter
from json import loads
from requests import get
from searx import settings
from searx import logger
@@ -32,13 +31,14 @@ from searx.utils import load_module, match_language

logger = logger.getChild('engines')

engine_dir = dirname(realpath(__file__))
engine_dir = Path(__file__).parent

engines = {}

categories = {'general': []}

languages = loads(open(engine_dir + '/../data/engines_languages.json', 'r', encoding='utf-8').read())
with open(engine_dir.parent / "data" / "engines_languages.json", encoding='utf-8') as fd:
    languages = json.load(fd)
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())]

+5 −6
Original line number Diff line number Diff line
import json
import re
import os
import sys
import unicodedata

from io import open
from pathlib import Path
from datetime import datetime


@@ -88,10 +87,10 @@ def response(resp):
def load():
    global db

    current_dir = os.path.dirname(os.path.realpath(__file__))
    json_data = open(current_dir + "/../data/currencies.json", 'r', encoding='utf-8').read()

    db = json.loads(json_data)
    with open(
        Path(__file__).parent.parent / "data" / "currencies.json", encoding='utf-8'
    ) as fd:
        db = json.load(fd)


load()
+1 −1
Original line number Diff line number Diff line
from collections import Iterable
from collections.abc import Iterable
from json import loads
from searx.url_utils import urlencode
from searx.utils import to_string
+4 −6
Original line number Diff line number Diff line
@@ -3,12 +3,12 @@ import hashlib
import hmac
import os
import re
from importlib.machinery import SourceFileLoader

from babel.core import get_global
from babel.dates import format_date
from babel import UnknownLocaleError
from codecs import getincrementalencoder
from imp import load_source
from numbers import Number
from os.path import splitext, join
from pathlib import Path
@@ -30,10 +30,8 @@ logger = logger.getChild('utils')
blocked_tags = ('script',
                'style')

useragents = json.load(open(
    Path(__file__).parent / "data" / "useragents.json",
    encoding='utf-8')
)
with open(Path(__file__).parent / "data" / "useragents.json", encoding='utf-8') as fd:
    useragents = json.load(fd)


def searx_useragent():
@@ -357,7 +355,7 @@ def load_module(filename, module_dir):
    if modname in sys.modules:
        del sys.modules[modname]
    filepath = join(module_dir, filename)
    module = load_source(modname, filepath)
    module = SourceFileLoader(modname, filepath).load_module()
    module.name = modname
    return module

Loading