__init__.py 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. # SPDX-License-Identifier: AGPL-3.0-or-later
  2. # lint: pylint
  3. """This module holds the *data* created by::
  4. make data.all
  5. """
  6. __all__ = [
  7. 'ENGINES_LANGUAGES',
  8. 'CURRENCIES',
  9. 'USER_AGENTS',
  10. 'EXTERNAL_URLS',
  11. 'WIKIDATA_UNITS',
  12. 'EXTERNAL_BANGS',
  13. 'OSM_KEYS_TAGS',
  14. 'ahmia_blacklist_loader',
  15. ]
  16. import json
  17. from pathlib import Path
  18. data_dir = Path(__file__).parent
  19. def _load(filename):
  20. with open(data_dir / filename, encoding='utf-8') as f:
  21. return json.load(f)
  22. def ahmia_blacklist_loader():
  23. """Load data from `ahmia_blacklist.txt` and return a list of MD5 values of onion
  24. names. The MD5 values are fetched by::
  25. searx_extra/update/update_ahmia_blacklist.py
  26. This function is used by :py:mod:`searx.plugins.ahmia_filter`.
  27. """
  28. with open(str(data_dir / 'ahmia_blacklist.txt'), encoding='utf-8') as f:
  29. return f.read().split()
  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')