__init__.py 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. # SPDX-License-Identifier: AGPL-3.0-or-later
  2. # lint: pylint
  3. """Engine related implementations
  4. .. note::
  5. The long term goal is to modularize all relevant implementations to the
  6. engines here in this Python package. In addition to improved modularization,
  7. this will also be necessary in part because the probability of circular
  8. imports will increase due to the increased typification of implementations in
  9. the future.
  10. ToDo:
  11. - move :py:obj:`searx.engines.load_engine` to a new module `searx.enginelib`.
  12. """
  13. from __future__ import annotations
  14. from typing import Union, Dict, List, Callable, TYPE_CHECKING
  15. if TYPE_CHECKING:
  16. from searx.enginelib import traits
  17. class Engine: # pylint: disable=too-few-public-methods
  18. """Class of engine instances build from YAML settings.
  19. Further documentation see :ref:`general engine configuration`.
  20. .. hint::
  21. This class is currently never initialized and only used for type hinting.
  22. """
  23. # Common options in the engine module
  24. engine_type: str
  25. """Type of the engine (:origin:`searx/search/processors`)"""
  26. paging: bool
  27. """Engine supports multiple pages."""
  28. time_range_support: bool
  29. """Engine supports search time range."""
  30. safesearch: bool
  31. """Engine supports SafeSearch"""
  32. language_support: bool
  33. """Engine supports languages (locales) search."""
  34. language: str
  35. """For an engine, when there is ``language: ...`` in the YAML settings the engine
  36. does support only this one language:
  37. .. code:: yaml
  38. - name: google french
  39. engine: google
  40. language: fr
  41. """
  42. region: str
  43. """For an engine, when there is ``region: ...`` in the YAML settings the engine
  44. does support only this one region::
  45. .. code:: yaml
  46. - name: google belgium
  47. engine: google
  48. region: fr-BE
  49. """
  50. fetch_traits: Callable
  51. """Function to to fetch engine's traits from origin."""
  52. traits: traits.EngineTraits
  53. """Traits of the engine."""
  54. # settings.yml
  55. categories: List[str]
  56. """Tabs, in which the engine is working."""
  57. name: str
  58. """Name that will be used across SearXNG to define this engine. In settings, on
  59. the result page .."""
  60. engine: str
  61. """Name of the python file used to handle requests and responses to and from
  62. this search engine (file name from :origin:`searx/engines` without
  63. ``.py``)."""
  64. enable_http: bool
  65. """Enable HTTP (by default only HTTPS is enabled)."""
  66. shortcut: str
  67. """Code used to execute bang requests (``!foo``)"""
  68. timeout: float
  69. """Specific timeout for search-engine."""
  70. display_error_messages: bool
  71. """Display error messages on the web UI."""
  72. proxies: dict
  73. """Set proxies for a specific engine (YAML):
  74. .. code:: yaml
  75. proxies :
  76. http: socks5://proxy:port
  77. https: socks5://proxy:port
  78. """
  79. disabled: bool
  80. """To disable by default the engine, but not deleting it. It will allow the
  81. user to manually activate it in the settings."""
  82. inactive: bool
  83. """Remove the engine from the settings (*disabled & removed*)."""
  84. about: dict
  85. """Additional fileds describing the engine.
  86. .. code:: yaml
  87. about:
  88. website: https://example.com
  89. wikidata_id: Q306656
  90. official_api_documentation: https://example.com/api-doc
  91. use_official_api: true
  92. require_api_key: true
  93. results: HTML
  94. """
  95. # deprecated properties
  96. _fetch_supported_languages: Callable # deprecated use fetch_traits
  97. supported_languages: Union[List[str], Dict[str, str]] # deprecated use traits
  98. language_aliases: Dict[str, str] # deprecated not needed when using triats
  99. supported_languages_url: str # deprecated not needed when using triats