.oO SearXNG Developer Documentation Oo.
Loading...
Searching...
No Matches
keyvalue.py
Go to the documentation of this file.
1# SPDX-License-Identifier: AGPL-3.0-or-later
2"""
3Typification of the *keyvalue* results. Results of this type are rendered in
4the :origin:`keyvalue.html <searx/templates/simple/result_templates/keyvalue.html>`
5template.
6
7----
8
9.. autoclass:: KeyValue
10 :members:
11 :show-inheritance:
12
13"""
14# pylint: disable=too-few-public-methods
15
16
17__all__ = ["KeyValue"]
18
19import typing
20from collections import OrderedDict
21
22from ._base import MainResult
23
24
25class KeyValue(MainResult, kw_only=True):
26 """Simple table view which maps *key* names (first col) to *values*
27 (second col)."""
28
29 template: str = "keyvalue.html"
30
31 kvmap: dict[str, typing.Any] | OrderedDict[str, typing.Any]
32 """Dictionary with keys and values. To sort keys, use :py:obj:`OrderedDict`."""
33
34 caption: str = ""
35 """Optional caption for this result."""
36
37 key_title: str = ""
38 """Optional title for the *key column*."""
39
40 value_title: str = ""
41 """Optional title for the *value column*."""
42
43 def __hash__(self) -> int:
44 """The KeyValues objects are checked for object identity, even if all
45 fields of two results have the same values, they are different from each
46 other.
47 """
48 return id(self)