on master help sign in
[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>

commitc697e350b5b78f684f36f15701afb9000ce116fc authorMarkus Heiser <markus.heiser@darmarit.de> dateSun 6 Jun 2021, 08:13 (5 years ago) parentc64a8f8
1 file changed+26−15
searx/data/__init__.py+26−15
searx/data/__init__.py+26−15
@@ -1,8 +1,10 @@
11# SPDX-License-Identifier: AGPL-3.0-or-later
2+# lint: pylint
3+"""This module holds the *data* created by::
24
3−import json
4−from pathlib import Path
5+ make data.all
56
7+"""
68
79__all__ = [
810 'ENGINES_LANGUAGES',
@@ -14,23 +16,32 @@ __all__ = [
1416 'OSM_KEYS_TAGS',
1517 'ahmia_blacklist_loader',
1618]
17−data_dir = Path(__file__).parent
1819
20+import json
21+from pathlib import Path
1922
20−def load(filename):
21− with open(data_dir / filename, encoding='utf-8') as fd:
22− return json.load(fd)
23+data_dir = Path(__file__).parent
2324
25+def _load(filename):
26+ with open(data_dir / filename, encoding='utf-8') as f:
27+ return json.load(f)
2428
2529def ahmia_blacklist_loader():
26− with open(str(data_dir / 'ahmia_blacklist.txt'), encoding='utf-8') as fd:
27− return fd.read().split()
30+ """Load data from `ahmia_blacklist.txt` and return a list of MD5 values of onion
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`.
2836
37+ """
38+ with open(str(data_dir / 'ahmia_blacklist.txt'), encoding='utf-8') as f:
39+ return f.read().split()
2940
30−ENGINES_LANGUAGES = load('engines_languages.json')
31−CURRENCIES = load('currencies.json')
32−USER_AGENTS = load('useragents.json')
33−EXTERNAL_URLS = load('external_urls.json')
34−WIKIDATA_UNITS = load('wikidata_units.json')
35−EXTERNAL_BANGS = load('external_bangs.json')
36−OSM_KEYS_TAGS = load('osm_keys_tags.json')
41+ENGINES_LANGUAGES = _load('engines_languages.json')
42+CURRENCIES = _load('currencies.json')
43+USER_AGENTS = _load('useragents.json')
44+EXTERNAL_URLS = _load('external_urls.json')
45+WIKIDATA_UNITS = _load('wikidata_units.json')
46+EXTERNAL_BANGS = _load('external_bangs.json')
47+OSM_KEYS_TAGS = _load('osm_keys_tags.json')