.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
14from __future__ import annotations
15
16__all__ = ["Result", "EngineResults", "AnswerSet", "Answer", "Translations"]
17
18import abc
19
20from searx import enginelib
21
22from ._base import Result, LegacyResult
23from .answer import AnswerSet, Answer, Translations
24
25
26class 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
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 """
add(self, Result result)
Definition __init__.py:39