summaryrefslogtreecommitdiff
path: root/searx/external_bang.py
diff options
context:
space:
mode:
authorAlexandre Flament <alex@al-f.net>2020-10-05 13:50:33 +0200
committerAlexandre Flament <alex@al-f.net>2020-10-07 10:29:34 +0200
commita9dc54bebc943000252975ef25ddcb51681fc284 (patch)
tree1cf83faca105df629ea06a3492884001d6b4d84c /searx/external_bang.py
parente30dc2f0ba481e033f127e5619d90cdc05d6db25 (diff)
downloadsearxng-a9dc54bebc943000252975ef25ddcb51681fc284.tar.gz
searxng-a9dc54bebc943000252975ef25ddcb51681fc284.zip
[mod] Add searx.data module
Instead of loading the data/*.json in different location, load these files in the new searx.data module.
Diffstat (limited to 'searx/external_bang.py')
-rw-r--r--searx/external_bang.py12
1 files changed, 4 insertions, 8 deletions
diff --git a/searx/external_bang.py b/searx/external_bang.py
index 92b6e6a09..104f85958 100644
--- a/searx/external_bang.py
+++ b/searx/external_bang.py
@@ -1,7 +1,4 @@
-import json
-from os.path import join
-
-from searx import searx_dir
+from searx.data import bangs_loader
# bangs data coming from the following url convert to json with
# https://raw.githubusercontent.com/jivesearch/jivesearch/master/bangs/bangs.toml
@@ -9,10 +6,9 @@ from searx import searx_dir
# NOTE only use the get_bang_url
bangs_data = {}
-with open(join(searx_dir, 'data/bangs.json'), encoding='utf-8') as json_file:
- for bang in json.load(json_file)['bang']:
- for trigger in bang["triggers"]:
- bangs_data[trigger] = {x: y for x, y in bang.items() if x != "triggers"}
+for bang in bangs_loader()['bang']:
+ for trigger in bang["triggers"]:
+ bangs_data[trigger] = {x: y for x, y in bang.items() if x != "triggers"}
def get_bang_url(search_query):