.oO SearXNG Developer Documentation Oo.
Loading...
Searching...
No Matches
searx.preferences.EnumStringSetting Class Reference
Inheritance diagram for searx.preferences.EnumStringSetting:
Collaboration diagram for searx.preferences.EnumStringSetting:

Public Member Functions

 __init__ (self, str default_value, Iterable[str] choices, bool locked=False)
 parse (self, str data)
Public Member Functions inherited from searx.preferences.Setting
 __init__ (self, t.Any default_value, bool locked=False)
 get_value (self)
 save (self, str name, flask.Response resp)

Public Attributes

Iterable[str] choices = choices
Public Attributes inherited from searx.preferences.Setting
t.Any value = default_value
bool locked = locked

Protected Member Functions

 _validate_selection (self, str selection)

Detailed Description

Setting of a value which can only come from the given choices

Definition at line 82 of file preferences.py.

Constructor & Destructor Documentation

◆ __init__()

searx.preferences.EnumStringSetting.__init__ ( self,
str default_value,
Iterable[str] choices,
bool locked = False )

Definition at line 87 of file preferences.py.

87 def __init__(self, default_value: str, choices: Iterable[str], locked: bool = False):
88 super().__init__(default_value, locked)
89 self.choices: Iterable[str] = choices
90 self._validate_selection(self.value)
91

References __init__().

Referenced by __init__().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Function Documentation

◆ _validate_selection()

searx.preferences.EnumStringSetting._validate_selection ( self,
str selection )
protected

Reimplemented in searx.preferences.SearchLanguageSetting.

Definition at line 92 of file preferences.py.

92 def _validate_selection(self, selection: str):
93 if selection not in self.choices:
94 raise ValidationException('Invalid value: "{0}"'.format(selection))
95

References choices.

Referenced by parse().

Here is the caller graph for this function:

◆ parse()

searx.preferences.EnumStringSetting.parse ( self,
str data )
Parse and validate ``data`` and store the result at ``self.value``

Reimplemented from searx.preferences.Setting.

Reimplemented in searx.preferences.SearchLanguageSetting.

Definition at line 96 of file preferences.py.

96 def parse(self, data: str):
97 """Parse and validate ``data`` and store the result at ``self.value``"""
98 self._validate_selection(data)
99 self.value = data
100
101

References _validate_selection(), and searx.preferences.Setting.value.

Here is the call graph for this function:

Member Data Documentation

◆ choices


The documentation for this class was generated from the following file: