on master help sign in
[mod] add utils/fetch_external_bangs.py

Based on duckduckgo bangs Store bangs on a trie to allow autocomplete (not in this commit)

commit7c1847d5f2f78392d4e7f6b4892d732f6520b3dc authorAlexandre Flament <alex@al-f.net> dateMon 22 Feb 2021, 18:03 (6 years ago) parent606aa79
7 files changed+19431−67945
Makefile+2−1 searx/data/__init__.py+2−5 searx/data/bangs.json−67913 searx/data/external_bangs.json+19067 searx/external_bang.py+76−26 tests/unit/test_external_bangs.py+123 utils/fetch_external_bangs.py+161
Makefile+2−1
@@ -194,7 +194,8 @@ PYLINT_FILES=\
194194 searx/engines/google_news.py \
195195 searx/engines/google_videos.py \
196196 searx/engines/google_images.py \
197− searx/engines/mediathekviewweb.py
197+ searx/engines/mediathekviewweb.py \
198+ utils/fetch_external_bangs.py
198199
199200test.pylint: pyenvinstall
200201 $(call cmd,pylint,$(PYLINT_FILES))
searx/data/__init__.py+2−5
@@ -2,7 +2,7 @@ import json
22from pathlib import Path
33
44
5−__init__ = ['ENGINES_LANGUGAGES', 'CURRENCIES', 'USER_AGENTS', 'EXTERNAL_URLS', 'WIKIDATA_UNITS',
5+__init__ = ['ENGINES_LANGUGAGES', 'CURRENCIES', 'USER_AGENTS', 'EXTERNAL_URLS', 'WIKIDATA_UNITS', 'EXTERNAL_BANGS',
66 'bangs_loader', 'ahmia_blacklist_loader']
77data_dir = Path(__file__).parent
88
@@ -12,10 +12,6 @@ def load(filename):
1212 return json.load(fd)
1313
1414
15−def bangs_loader():
16− return load('bangs.json')
17−
18−
1915def ahmia_blacklist_loader():
2016 with open(str(data_dir / 'ahmia_blacklist.txt'), encoding='utf-8') as fd:
2117 return fd.read().split()
@@ -26,3 +22,4 @@ CURRENCIES = load('currencies.json')
2622USER_AGENTS = load('useragents.json')
2723EXTERNAL_URLS = load('external_urls.json')
2824WIKIDATA_UNITS = load('wikidata_units.json')
25+EXTERNAL_BANGS = load('external_bangs.json')
searx/data/bangs.jsondeleted−67913

This diff is too big to show here.

searx/data/external_bangs.jsonnew file+19067

This diff is too big to show here.

searx/external_bang.py+76−26

This diff is too big to show here.

tests/unit/test_external_bangs.pynew file+123

This diff is too big to show here.

utils/fetch_external_bangs.pynew file+161

This diff is too big to show here.