on master help sign in
[pylint] searx/data/__init__.py
c697e35Markus Heiser
searx/data/__init__.py+26−15
@@ -1,8 +1,10 @@
1# SPDX-License-Identifier: AGPL-3.0-or-later
1# SPDX-License-Identifier: AGPL-3.0-or-later
2+# lint: pylint
3+"""This module holds the *data* created by::
2
4
3−import json
5+ make data.all
4−from pathlib import Path
5
6
7+"""
6
8
7__all__ = [
9__all__ = [
8 'ENGINES_LANGUAGES',
10 'ENGINES_LANGUAGES',
@@ -14,23 +16,32 @@ __all__ = [
14 'OSM_KEYS_TAGS',
16 'OSM_KEYS_TAGS',
15 'ahmia_blacklist_loader',
17 'ahmia_blacklist_loader',
16]
18]
17−data_dir = Path(__file__).parent
18
19
20+import json
21+from pathlib import Path
19
22
20−def load(filename):
23+data_dir = Path(__file__).parent
21− with open(data_dir / filename, encoding='utf-8') as fd:
22− return json.load(fd)
23
24
25+def _load(filename):
26+ with open(data_dir / filename, encoding='utf-8') as f:
27+ return json.load(f)
24
28
25def ahmia_blacklist_loader():
29def ahmia_blacklist_loader():
26− with open(str(data_dir / 'ahmia_blacklist.txt'), encoding='utf-8') as fd:
30+ """Load data from `ahmia_blacklist.txt` and return a list of MD5 values of onion
27− return fd.read().split()
31+ names. The MD5 values are fetched by::
32+
33+ searx_extra/update/update_ahmia_blacklist.py
34+
35+ This function is used by :py:mod:`searx.plugins.ahmia_filter`.
28
36
37+ """
38+ with open(str(data_dir / 'ahmia_blacklist.txt'), encoding='utf-8') as f:
39+ return f.read().split()
29
40
30−ENGINES_LANGUAGES = load('engines_languages.json')
41+ENGINES_LANGUAGES = _load('engines_languages.json')
31−CURRENCIES = load('currencies.json')
42+CURRENCIES = _load('currencies.json')
32−USER_AGENTS = load('useragents.json')
43+USER_AGENTS = _load('useragents.json')
33−EXTERNAL_URLS = load('external_urls.json')
44+EXTERNAL_URLS = _load('external_urls.json')
34−WIKIDATA_UNITS = load('wikidata_units.json')
45+WIKIDATA_UNITS = _load('wikidata_units.json')
35−EXTERNAL_BANGS = load('external_bangs.json')
46+EXTERNAL_BANGS = _load('external_bangs.json')
36−OSM_KEYS_TAGS = load('osm_keys_tags.json')
47+OSM_KEYS_TAGS = _load('osm_keys_tags.json')