.oO SearXNG Developer Documentation Oo.
Loading...
Searching...
No Matches
__init__.py
Go to the documentation of this file.
1
# SPDX-License-Identifier: AGPL-3.0-or-later
2
"""Typification of the result items generated by the *engines*, *answerers* and
3
*plugins*.
4
5
.. note::
6
7
We are at the beginning of typing the results. Further typing will follow,
8
but this is a very large task that we will only be able to implement
9
gradually. For more, please read :ref:`result types`.
10
11
"""
12
# pylint: disable=too-few-public-methods
13
14
from
__future__
import
annotations
15
16
__all__ = [
"Result"
,
"MainResult"
,
"KeyValue"
,
"EngineResults"
,
"AnswerSet"
,
"Answer"
,
"Translations"
,
"WeatherAnswer"
]
17
18
import
abc
19
20
from
searx
import
enginelib
21
22
from
._base
import
Result, MainResult, LegacyResult
23
from
.answer
import
AnswerSet, Answer, Translations, WeatherAnswer
24
from
.keyvalue
import
KeyValue
25
26
27
class
ResultList
(list, abc.ABC):
28
"""Base class of all result lists (abstract)."""
29
30
class
types
:
# pylint: disable=invalid-name
31
"""The collection of result types (which have already been implemented)."""
32
33
Answer = Answer
34
KeyValue = KeyValue
35
MainResult = MainResult
36
Result = Result
37
Translations = Translations
38
WeatherAnswer = WeatherAnswer
39
40
# for backward compatibility
41
LegacyResult = LegacyResult
42
43
def
__init__
(self):
44
# pylint: disable=useless-parent-delegation
45
super().
__init__
()
46
47
def
add
(self, result: Result | LegacyResult):
48
"""Add a :py:`Result` item to the result list."""
49
self.append(result)
50
51
52
class
EngineResults
(
ResultList
):
53
"""Result list that should be used by engine developers. For convenience,
54
engine developers don't need to import types / see :py:obj:`ResultList.types`.
55
56
.. code:: python
57
58
from searx.result_types import EngineResults
59
...
60
def response(resp) -> EngineResults:
61
res = EngineResults()
62
...
63
res.add( res.types.Answer(answer="lorem ipsum ..", url="https://example.org") )
64
...
65
return res
66
"""
searx.result_types.EngineResults
Definition
__init__.py:52
searx.result_types.ResultList.types
Definition
__init__.py:30
searx.result_types.ResultList
Definition
__init__.py:27
searx.result_types.ResultList.__init__
__init__(self)
Definition
__init__.py:43
searx.result_types.ResultList.add
add(self, Result|LegacyResult result)
Definition
__init__.py:47
searxng
searx
result_types
__init__.py
Generated on Sun Jun 1 2025 21:11:46 for .oO SearXNG Developer Documentation Oo. by
1.13.2