summaryrefslogtreecommitdiff
path: root/searx/engines/currency_convert.py
diff options
context:
space:
mode:
authorAdam Tauber <asciimoo@gmail.com>2017-05-15 14:23:23 +0200
committerGitHub <noreply@github.com>2017-05-15 14:23:23 +0200
commit4cffd78650c3f1dfce413ae0a1cd0453ebe6f277 (patch)
treeac65990c72156def2d49e81d981f0b3beda4fd2e /searx/engines/currency_convert.py
parent46a2c63f8e1c3819cceff2d61fe9106051e8ecee (diff)
parent52e615dede8538c36f569d2cf07835427a9a0db6 (diff)
downloadsearxng-4cffd78650c3f1dfce413ae0a1cd0453ebe6f277.tar.gz
searxng-4cffd78650c3f1dfce413ae0a1cd0453ebe6f277.zip
Merge pull request #913 from asciimoo/py3
Add Python3 compatibility
Diffstat (limited to 'searx/engines/currency_convert.py')
-rw-r--r--searx/engines/currency_convert.py14
1 files changed, 9 insertions, 5 deletions
diff --git a/searx/engines/currency_convert.py b/searx/engines/currency_convert.py
index bc839cfb5..1218d4849 100644
--- a/searx/engines/currency_convert.py
+++ b/searx/engines/currency_convert.py
@@ -1,21 +1,25 @@
-from datetime import datetime
+import json
import re
import os
-import json
+import sys
import unicodedata
+from datetime import datetime
+
+if sys.version_info[0] == 3:
+ unicode = str
categories = []
url = 'https://download.finance.yahoo.com/d/quotes.csv?e=.csv&f=sl1d1t1&s={query}=X'
weight = 100
-parser_re = re.compile(u'.*?(\\d+(?:\\.\\d+)?) ([^.0-9]+) (?:in|to) ([^.0-9]+)', re.I) # noqa
+parser_re = re.compile(b'.*?(\\d+(?:\\.\\d+)?) ([^.0-9]+) (?:in|to) ([^.0-9]+)', re.I)
db = 1
def normalize_name(name):
- name = name.lower().replace('-', ' ').rstrip('s')
+ name = name.decode('utf-8').lower().replace('-', ' ').rstrip('s')
name = re.sub(' +', ' ', name)
return unicodedata.normalize('NFKD', name).lower()
@@ -35,7 +39,7 @@ def iso4217_to_name(iso4217, language):
def request(query, params):
- m = parser_re.match(unicode(query, 'utf8'))
+ m = parser_re.match(query)
if not m:
# wrong query
return params