summaryrefslogtreecommitdiff
path: root/searx/engines/currency_convert.py
diff options
context:
space:
mode:
Diffstat (limited to 'searx/engines/currency_convert.py')
-rw-r--r--searx/engines/currency_convert.py28
1 files changed, 7 insertions, 21 deletions
diff --git a/searx/engines/currency_convert.py b/searx/engines/currency_convert.py
index c6067c4a8..4a82cfdca 100644
--- a/searx/engines/currency_convert.py
+++ b/searx/engines/currency_convert.py
@@ -1,11 +1,11 @@
import json
import re
-import os
import unicodedata
-from io import open
from datetime import datetime
+from searx.data import CURRENCIES
+
categories = []
url = 'https://duckduckgo.com/js/spice/currency/1/{0}/{1}'
@@ -13,8 +13,6 @@ weight = 100
parser_re = re.compile('.*?(\\d+(?:\\.\\d+)?) ([^.0-9]+) (?:in|to) ([^.0-9]+)', re.I)
-db = 1
-
def normalize_name(name):
name = name.lower().replace('-', ' ').rstrip('s')
@@ -23,17 +21,17 @@ def normalize_name(name):
def name_to_iso4217(name):
- global db
+ global CURRENCIES
name = normalize_name(name)
- currencies = db['names'].get(name, [name])
- return currencies[0]
+ currency = CURRENCIES['names'].get(name, [name])
+ return currency[0]
def iso4217_to_name(iso4217, language):
- global db
+ global CURRENCIES
- return db['iso4217'].get(iso4217, {}).get(language, iso4217)
+ return CURRENCIES['iso4217'].get(iso4217, {}).get(language, iso4217)
def request(query, params):
@@ -82,15 +80,3 @@ def response(resp):
results.append({'answer': answer, 'url': url})
return results
-
-
-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)
-
-
-load()