mirror of
https://github.com/searxng/searxng
synced 2024-01-01 19:24:07 +01:00

The intention of this patch is to improve modularization & documentation of the implementations about the *result* items. This patch does not contain any functional change! Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
37 lines
923 B
Python
37 lines
923 B
Python
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
# lint: pylint
|
|
"""Answer item in the result list. The answer result item is used in
|
|
the :origin:`results.html <searx/templates/simple/results.html>` template.
|
|
|
|
A answer item is a dictionary type with dedicated keys and values.
|
|
|
|
.. code:: python
|
|
|
|
results.append({
|
|
'answer' : str,
|
|
'url' : str,
|
|
})
|
|
|
|
answer : ``str``
|
|
The answer string append by the engine.
|
|
|
|
url : ``str``
|
|
A link that is related to the answer (e.g. the origin of the answer).
|
|
|
|
"""
|
|
|
|
|
|
def is_answer(result):
|
|
"""Returns ``True`` if result type is :py:obj:`.answer`, otherwise ``False``
|
|
|
|
In the result list a answer item is identified by the existence of the key
|
|
``answer``.
|
|
"""
|
|
return 'answer' in result
|
|
|
|
|
|
class Answers(dict):
|
|
"""Dictionary of answers in the :py:obj:`.container.ResultContainer`"""
|
|
|
|
def add(self, result):
|
|
self[result['answer']] = result
|