1 Commits

Author SHA1 Message Date
searxng-bot 19cb234514 [l10n] update translations from Weblate
54de6653b - 2026-04-15 - AndersNordh <andersnordh@noreply.codeberg.org>
e410bed58 - 2026-04-15 - AndersNordh <andersnordh@noreply.codeberg.org>
2026-04-24 13:03:49 +00:00
+11 -13
View File
@@ -32,7 +32,7 @@ import msgspec
from searx import logger as log
WHITESPACE_REGEX = re.compile('( |\t|\n)+', re.M | re.U)
UNSET = object()
UNKNOWN = object()
def _normalize_url_fields(result: "Result | LegacyResult"):
@@ -326,13 +326,12 @@ class Result(msgspec.Struct, kw_only=True):
def defaults_from(self, other: "Result"):
"""Fields not set in *self* will be updated from the field values of the
*other*. If a field is set (exists) but contains an empty string
or the value ``None``, it is also considered *not set*.
*other*.
"""
for field_name in self.__struct_fields__:
self_val = getattr(self, field_name, UNSET)
other_val = getattr(other, field_name, UNSET)
if self_val is UNSET and other_val not in (UNSET, "", None):
self_val = getattr(self, field_name, False)
other_val = getattr(other, field_name, False)
if self_val:
setattr(self, field_name, other_val)
@@ -441,6 +440,8 @@ class LegacyResult(dict[str, t.Any]):
Do not use this class in your own implementations!
"""
UNSET: object = object()
# emulate field types from type class Result
url: str | None
template: str
@@ -511,7 +512,7 @@ class LegacyResult(dict[str, t.Any]):
)
def __getattr__(self, name: str, default: t.Any = UNSET) -> t.Any:
if default == UNSET and name not in self:
if default == self.UNSET and name not in self:
raise AttributeError(f"LegacyResult object has no field named: {name}")
return self[name]
@@ -562,12 +563,9 @@ class LegacyResult(dict[str, t.Any]):
self.engines.add(self.engine)
def defaults_from(self, other: "LegacyResult"):
# If a field is set (exists) but contains an empty string or the value
# ``None``, it is also considered *not set*.
for field_name, other_val in other.items():
self_val = self.get(field_name, UNSET)
if self_val is UNSET and other_val not in ("", UNSET):
self[field_name] = other_val
for k, v in other.items():
if not self.get(k):
self[k] = v
def filter_urls(self, filter_func: "Callable[[Result | LegacyResult, str, str], str | bool]"):
"""See :py:obj:`Result.filter_urls`"""