__init__.py 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. 'ENGINE_TRAITS',
  8. 'CURRENCIES',
  9. 'USER_AGENTS',
  10. 'EXTERNAL_URLS',
  11. 'WIKIDATA_UNITS',
  12. 'EXTERNAL_BANGS',
  13. 'OSM_KEYS_TAGS',
  14. 'ENGINE_DESCRIPTIONS',
  15. 'LOCALES',
  16. 'ahmia_blacklist_loader',
  17. ]
  18. import json
  19. from pathlib import Path
  20. data_dir = Path(__file__).parent
  21. def _load(filename):
  22. with open(data_dir / filename, encoding='utf-8') as f:
  23. return json.load(f)
  24. def ahmia_blacklist_loader():
  25. """Load data from `ahmia_blacklist.txt` and return a list of MD5 values of onion
  26. names. The MD5 values are fetched by::
  27. searxng_extra/update/update_ahmia_blacklist.py
  28. This function is used by :py:mod:`searx.plugins.ahmia_filter`.
  29. """
  30. with open(data_dir / 'ahmia_blacklist.txt', encoding='utf-8') as f:
  31. return f.read().split()
  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')
  39. ENGINE_TRAITS = _load('engine_traits.json')
  40. LOCALES = _load('locales.json')