Browse Source

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

[fix] Read utf-8 files (settings, languages, currency) with Python3.5
Adam Tauber 6 years ago
parent
commit
4ad5e6ad4f
No account linked to committer's email
4 changed files with 7 additions and 3 deletions
  1. 1
    0
      .travis.yml
  2. 2
    1
      searx/__init__.py
  3. 2
    1
      searx/engines/__init__.py
  4. 2
    1
      searx/engines/currency_convert.py

+ 1
- 0
.travis.yml View File

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

+ 2
- 1
searx/__init__.py View File

19
 import logging
19
 import logging
20
 from os import environ
20
 from os import environ
21
 from os.path import realpath, dirname, join, abspath, isfile
21
 from os.path import realpath, dirname, join, abspath, isfile
22
+from io import open
22
 from ssl import OPENSSL_VERSION_INFO, OPENSSL_VERSION
23
 from ssl import OPENSSL_VERSION_INFO, OPENSSL_VERSION
23
 try:
24
 try:
24
     from yaml import load
25
     from yaml import load
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
 '''

+ 2
- 1
searx/engines/__init__.py View File

19
 import sys
19
 import sys
20
 import threading
20
 import threading
21
 from os.path import realpath, dirname
21
 from os.path import realpath, dirname
22
+from io import open
22
 from flask_babel import gettext
23
 from flask_babel import gettext
23
 from operator import itemgetter
24
 from operator import itemgetter
24
 from json import loads
25
 from json import loads
36
 
37
 
37
 categories = {'general': []}
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
 engine_shortcuts = {}
42
 engine_shortcuts = {}
42
 engine_default_args = {'paging': False,
43
 engine_default_args = {'paging': False,

+ 2
- 1
searx/engines/currency_convert.py View File

4
 import sys
4
 import sys
5
 import unicodedata
5
 import unicodedata
6
 
6
 
7
+from io import open
7
 from datetime import datetime
8
 from datetime import datetime
8
 
9
 
9
 if sys.version_info[0] == 3:
10
 if sys.version_info[0] == 3:
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