__init__.py 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. 'ENGINE_DESCRIPTIONS',
  15. 'ahmia_blacklist_loader',
  16. ]
  17. import json
  18. from pathlib import Path
  19. data_dir = Path(__file__).parent
  20. def _load(filename):
  21. with open(data_dir / filename, encoding='utf-8') as f:
  22. return json.load(f)
  23. def ahmia_blacklist_loader():
  24. """Load data from `ahmia_blacklist.txt` and return a list of MD5 values of onion
  25. names. The MD5 values are fetched by::
  26. searxng_extra/update/update_ahmia_blacklist.py
  27. This function is used by :py:mod:`searx.plugins.ahmia_filter`.
  28. """
  29. with open(str(data_dir / 'ahmia_blacklist.txt'), encoding='utf-8') as f:
  30. return f.read().split()
  31. ENGINES_LANGUAGES = _load('engines_languages.json')
  32. CURRENCIES = _load('currencies.json')
  33. USER_AGENTS = _load('useragents.json')
  34. EXTERNAL_URLS = _load('external_urls.json')
  35. WIKIDATA_UNITS = _load('wikidata_units.json')
  36. EXTERNAL_BANGS = _load('external_bangs.json')
  37. OSM_KEYS_TAGS = _load('osm_keys_tags.json')
  38. ENGINE_DESCRIPTIONS = _load('engine_descriptions.json')