Kaynağa Gözat

Merge pull request #1148 from MarcAbonce/python3.5-fix

[fix] Read utf-8 files (settings, languages, currency) with Python3.5
Adam Tauber 6 yıl önce
ebeveyn
işleme
4ad5e6ad4f
No account linked to committer's email

+ 1
- 0
.travis.yml Dosyayı Görüntüle

@@ -9,6 +9,7 @@ addons:
9 9
 language: python
10 10
 python:
11 11
   - "2.7"
12
+  - "3.5"
12 13
   - "3.6"
13 14
 before_install:
14 15
   - "export DISPLAY=:99.0"

+ 2
- 1
searx/__init__.py Dosyayı Görüntüle

@@ -19,6 +19,7 @@ import certifi
19 19
 import logging
20 20
 from os import environ
21 21
 from os.path import realpath, dirname, join, abspath, isfile
22
+from io import open
22 23
 from ssl import OPENSSL_VERSION_INFO, OPENSSL_VERSION
23 24
 try:
24 25
     from yaml import load
@@ -50,7 +51,7 @@ if not settings_path:
50 51
     raise Exception('settings.yml not found')
51 52
 
52 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 55
     settings = load(settings_yaml)
55 56
 
56 57
 '''

+ 2
- 1
searx/engines/__init__.py Dosyayı Görüntüle

@@ -19,6 +19,7 @@ along with searx. If not, see < http://www.gnu.org/licenses/ >.
19 19
 import sys
20 20
 import threading
21 21
 from os.path import realpath, dirname
22
+from io import open
22 23
 from flask_babel import gettext
23 24
 from operator import itemgetter
24 25
 from json import loads
@@ -36,7 +37,7 @@ engines = {}
36 37
 
37 38
 categories = {'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
 
41 42
 engine_shortcuts = {}
42 43
 engine_default_args = {'paging': False,

+ 2
- 1
searx/engines/currency_convert.py Dosyayı Görüntüle

@@ -4,6 +4,7 @@ import os
4 4
 import sys
5 5
 import unicodedata
6 6
 
7
+from io import open
7 8
 from datetime import datetime
8 9
 
9 10
 if sys.version_info[0] == 3:
@@ -94,7 +95,7 @@ def load():
94 95
     global db
95 96
 
96 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 100
     db = json.loads(json_data)
100 101