forked from zaclys/searxng
[pylint] searx/data/__init__.py
BTW: add doc strings and moved __all__ to the top [1] [1] https://www.python.org/dev/peps/pep-0008/#module-level-dunder-names Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
This commit is contained in:
parent
2e5d823162
commit
5cf1ae2672
|
@ -1,8 +1,10 @@
|
||||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
# lint: pylint
|
||||||
|
"""This module holds the *data* created by::
|
||||||
|
|
||||||
import json
|
make data.all
|
||||||
from pathlib import Path
|
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
'ENGINES_LANGUAGES',
|
'ENGINES_LANGUAGES',
|
||||||
|
@ -14,23 +16,32 @@ __all__ = [
|
||||||
'OSM_KEYS_TAGS',
|
'OSM_KEYS_TAGS',
|
||||||
'ahmia_blacklist_loader',
|
'ahmia_blacklist_loader',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
import json
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
data_dir = Path(__file__).parent
|
data_dir = Path(__file__).parent
|
||||||
|
|
||||||
|
def _load(filename):
|
||||||
def load(filename):
|
with open(data_dir / filename, encoding='utf-8') as f:
|
||||||
with open(data_dir / filename, encoding='utf-8') as fd:
|
return json.load(f)
|
||||||
return json.load(fd)
|
|
||||||
|
|
||||||
|
|
||||||
def ahmia_blacklist_loader():
|
def ahmia_blacklist_loader():
|
||||||
with open(str(data_dir / 'ahmia_blacklist.txt'), encoding='utf-8') as fd:
|
"""Load data from `ahmia_blacklist.txt` and return a list of MD5 values of onion
|
||||||
return fd.read().split()
|
names. The MD5 values are fetched by::
|
||||||
|
|
||||||
|
searx_extra/update/update_ahmia_blacklist.py
|
||||||
|
|
||||||
ENGINES_LANGUAGES = load('engines_languages.json')
|
This function is used by :py:mod:`searx.plugins.ahmia_filter`.
|
||||||
CURRENCIES = load('currencies.json')
|
|
||||||
USER_AGENTS = load('useragents.json')
|
"""
|
||||||
EXTERNAL_URLS = load('external_urls.json')
|
with open(str(data_dir / 'ahmia_blacklist.txt'), encoding='utf-8') as f:
|
||||||
WIKIDATA_UNITS = load('wikidata_units.json')
|
return f.read().split()
|
||||||
EXTERNAL_BANGS = load('external_bangs.json')
|
|
||||||
OSM_KEYS_TAGS = load('osm_keys_tags.json')
|
ENGINES_LANGUAGES = _load('engines_languages.json')
|
||||||
|
CURRENCIES = _load('currencies.json')
|
||||||
|
USER_AGENTS = _load('useragents.json')
|
||||||
|
EXTERNAL_URLS = _load('external_urls.json')
|
||||||
|
WIKIDATA_UNITS = _load('wikidata_units.json')
|
||||||
|
EXTERNAL_BANGS = _load('external_bangs.json')
|
||||||
|
OSM_KEYS_TAGS = _load('osm_keys_tags.json')
|
||||||
|
|
Loading…
Reference in New Issue