__init__.py 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. # SPDX-License-Identifier: AGPL-3.0-or-later
  2. """This module holds the *data* created by::
  3. make data.all
  4. """
  5. __all__ = [
  6. 'ENGINE_TRAITS',
  7. 'CURRENCIES',
  8. 'USER_AGENTS',
  9. 'EXTERNAL_URLS',
  10. 'WIKIDATA_UNITS',
  11. 'EXTERNAL_BANGS',
  12. 'OSM_KEYS_TAGS',
  13. 'ENGINE_DESCRIPTIONS',
  14. 'LOCALES',
  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(data_dir / 'ahmia_blacklist.txt', encoding='utf-8') as f:
  30. return f.read().split()
  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')
  37. ENGINE_DESCRIPTIONS = _load('engine_descriptions.json')
  38. ENGINE_TRAITS = _load('engine_traits.json')
  39. LOCALES = _load('locales.json')