on master help sign in
[fix] read utf-8 files (settings, languages, currency) with python3.5
829032fMarc Abonce Seguin
searx/__init__.py+2−1
@@ -19,6 +19,7 @@ import certifi
19import logging
19import logging
20from os import environ
20from os import environ
21from os.path import realpath, dirname, join, abspath, isfile
21from os.path import realpath, dirname, join, abspath, isfile
22+from io import open
22from ssl import OPENSSL_VERSION_INFO, OPENSSL_VERSION
23from ssl import OPENSSL_VERSION_INFO, OPENSSL_VERSION
23try:
24try:
24 from yaml import load
25 from yaml import load
@@ -50,7 +51,7 @@ if not settings_path:
50 raise Exception('settings.yml not found')
51 raise Exception('settings.yml not found')
51
52
52# load settings
53# load settings
53−with open(settings_path, 'rb') as settings_yaml:
54+with open(settings_path, 'r', encoding='utf-8') as settings_yaml:
54 settings = load(settings_yaml)
55 settings = load(settings_yaml)
55
56
56'''
57'''
searx/engines/__init__.py+2−1
@@ -19,6 +19,7 @@ along with searx. If not, see < http://www.gnu.org/licenses/ >.
19import sys
19import sys
20import threading
20import threading
21from os.path import realpath, dirname
21from os.path import realpath, dirname
22+from io import open
22from flask_babel import gettext
23from flask_babel import gettext
23from operator import itemgetter
24from operator import itemgetter
24from json import loads
25from json import loads
@@ -36,7 +37,7 @@ engines = {}
36
37
37categories = {'general': []}
38categories = {'general': []}
38
39
39−languages = loads(open(engine_dir + '/../data/engines_languages.json', 'rb').read())
40+languages = loads(open(engine_dir + '/../data/engines_languages.json', 'r', encoding='utf-8').read())
40
41
41engine_shortcuts = {}
42engine_shortcuts = {}
42engine_default_args = {'paging': False,
43engine_default_args = {'paging': False,
searx/engines/currency_convert.py+2−1
@@ -4,6 +4,7 @@ import os
4import sys
4import sys
5import unicodedata
5import unicodedata
6
6
7+from io import open
7from datetime import datetime
8from datetime import datetime
8
9
9if sys.version_info[0] == 3:
10if sys.version_info[0] == 3:
@@ -94,7 +95,7 @@ def load():
94 global db
95 global db
95
96
96 current_dir = os.path.dirname(os.path.realpath(__file__))
97 current_dir = os.path.dirname(os.path.realpath(__file__))
97− json_data = open(current_dir + "/../data/currencies.json", 'rb').read()
98+ json_data = open(current_dir + "/../data/currencies.json", 'r', encoding='utf-8').read()
98
99
99 db = json.loads(json_data)
100 db = json.loads(json_data)
100
101