.oO SearXNG Developer Documentation Oo.
|
Public Member Functions | |
get_language (self, str searxng_locale, default=None) | |
get_region (self, str searxng_locale, default=None) | |
bool | is_locale_supported (self, str searxng_locale) |
copy (self) | |
Union[ 'EngineTraits', None] | fetch_traits (cls, Engine engine) |
set_traits (self, Engine engine) | |
Public Attributes | |
str | data_type = 'traits_v1': |
Static Public Attributes | |
Dict | regions = dataclasses.field(default_factory=dict) |
Dict | languages = dataclasses.field(default_factory=dict) |
Optional | all_locale = None |
Literal | data_type = 'traits_v1' |
Dict | custom = dataclasses.field(default_factory=dict) |
Protected Member Functions | |
_set_traits_v1 (self, Engine engine) | |
|
protected |
Definition at line 162 of file traits.py.
References searx.enginelib.traits.EngineTraits.copy().
Referenced by searx.enginelib.traits.EngineTraits.set_traits().
searx.enginelib.traits.EngineTraits.copy | ( | self | ) |
Create a copy of the dataclass object.
Definition at line 132 of file traits.py.
Referenced by searx.enginelib.traits.EngineTraits._set_traits_v1().
Union['EngineTraits', None] searx.enginelib.traits.EngineTraits.fetch_traits | ( | cls, | |
Engine | engine ) |
Call a function ``fetch_traits(engine_traits)`` from engines namespace to fetch and set properties from the origin engine in the object ``engine_traits``. If function does not exists, ``None`` is returned.
Reimplemented in searx.enginelib.traits.EngineTraitsMap.
Definition at line 137 of file traits.py.
searx.enginelib.traits.EngineTraits.get_language | ( | self, | |
str | searxng_locale, | ||
default = None ) |
Return engine's language string that *best fits* to SearXNG's locale. :param searxng_locale: SearXNG's internal representation of locale selected by the user. :param default: engine's default language The *best fits* rules are implemented in :py:obj:`searx.locales.get_engine_locale`. Except for the special value ``all`` which is determined from :py:obj:`EngineTraits.all_locale`.
Definition at line 87 of file traits.py.
References searx.enginelib.traits.EngineTraits.all_locale, searx.enginelib.traits.EngineTraits.languages, searx.query.RawTextQuery.languages, searx.search.checker.impl.ResultContainerTests.languages, and searx.search.checker.impl.TestResults.languages.
Referenced by searx.enginelib.traits.EngineTraits.is_locale_supported().
searx.enginelib.traits.EngineTraits.get_region | ( | self, | |
str | searxng_locale, | ||
default = None ) |
Return engine's region string that best fits to SearXNG's locale. :param searxng_locale: SearXNG's internal representation of locale selected by the user. :param default: engine's default region The *best fits* rules are implemented in :py:obj:`searx.locales.get_engine_locale`. Except for the special value ``all`` which is determined from :py:obj:`EngineTraits.all_locale`.
Definition at line 103 of file traits.py.
References searx.enginelib.traits.EngineTraits.all_locale, and searx.enginelib.traits.EngineTraits.regions.
Referenced by searx.enginelib.traits.EngineTraits.is_locale_supported().
bool searx.enginelib.traits.EngineTraits.is_locale_supported | ( | self, | |
str | searxng_locale ) |
A *locale* (SearXNG's internal representation) is considered to be supported by the engine if the *region* or the *language* is supported by the engine. For verification the functions :py:func:`EngineTraits.get_region` and :py:func:`EngineTraits.get_language` are used.
Definition at line 119 of file traits.py.
References searx.enginelib.traits.EngineTraits.data_type, searx.enginelib.traits.EngineTraits.get_language(), and searx.enginelib.traits.EngineTraits.get_region().
searx.enginelib.traits.EngineTraits.set_traits | ( | self, | |
Engine | engine ) |
Set traits from self object in a :py:obj:`.Engine` namespace. :param engine: engine instance build by :py:func:`searx.engines.load_engine`
Reimplemented in searx.enginelib.traits.EngineTraitsMap.
Definition at line 151 of file traits.py.
References searx.enginelib.traits.EngineTraits._set_traits_v1(), and searx.enginelib.traits.EngineTraits.data_type.
|
static |
Definition at line 74 of file traits.py.
Referenced by searx.enginelib.traits.EngineTraits.get_language(), and searx.enginelib.traits.EngineTraits.get_region().
|
static |
|
static |
Definition at line 79 of file traits.py.
Referenced by searx.enginelib.traits.EngineTraits.is_locale_supported(), and searx.enginelib.traits.EngineTraits.set_traits().
str searx.enginelib.traits.EngineTraits.data_type = 'traits_v1': |
Definition at line 130 of file traits.py.
Referenced by searx.enginelib.traits.EngineTraits.is_locale_supported(), and searx.enginelib.traits.EngineTraits.set_traits().
|
static |
Definition at line 57 of file traits.py.
Referenced by searx.search.checker.impl.ResultContainerTests._add_language(), searx.search.checker.impl.TestResults.add_language(), and searx.enginelib.traits.EngineTraits.get_language().
|
static |
Definition at line 40 of file traits.py.
Referenced by searx.enginelib.traits.EngineTraits.get_region().