.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"
,
"EngineResults"
,
"AnswerSet"
,
"Answer"
,
"Translations"
]
17
18
import
abc
19
20
from
searx
import
enginelib
21
22
from
._base
import
Result, LegacyResult
23
from
.answer
import
AnswerSet, Answer, Translations
24
25
26
class
ResultList
(list, abc.ABC):
27
"""Base class of all result lists (abstract)."""
28
29
class
types
:
# pylint: disable=invalid-name
30
"""The collection of result types (which have already been implemented)."""
31
32
Answer = Answer
33
Translations = Translations
34
35
def
__init__
(self):
36
# pylint: disable=useless-parent-delegation
37
super().
__init__
()
38
39
def
add
(self, result: Result):
40
"""Add a :py:`Result` item to the result list."""
41
self.append(result)
42
43
44
class
EngineResults
(
ResultList
):
45
"""Result list that should be used by engine developers. For convenience,
46
engine developers don't need to import types / see :py:obj:`ResultList.types`.
47
48
.. code:: python
49
50
from searx.result_types import EngineResults
51
...
52
def response(resp) -> EngineResults:
53
res = EngineResults()
54
...
55
res.add( res.types.Answer(answer="lorem ipsum ..", url="https://example.org") )
56
...
57
return res
58
"""
searx.result_types.EngineResults
Definition
__init__.py:44
searx.result_types.ResultList.types
Definition
__init__.py:29
searx.result_types.ResultList
Definition
__init__.py:26
searx.result_types.ResultList.__init__
__init__(self)
Definition
__init__.py:35
searx.result_types.ResultList.add
add(self, Result result)
Definition
__init__.py:39
searxng
searx
result_types
__init__.py
Generated on Mon Feb 17 2025 20:49:38 for .oO SearXNG Developer Documentation Oo. by
1.13.2