forked from zaclys/searxng
[mod] Add searx.data module
Instead of loading the data/*.json in different location, load these files in the new searx.data module.
This commit is contained in:
parent
e30dc2f0ba
commit
a9dc54bebc
5 changed files with 37 additions and 41 deletions
|
|
@ -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):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue