.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, locked=False)
 
 parse (self, str data)
 
- Public Member Functions inherited from searx.preferences.Setting
 __init__ (self, default_value, bool locked=False)
 
 get_value (self)
 
 save (self, str name, flask.Response resp)
 

Public Attributes

 choices = choices
 
- Public Attributes inherited from searx.preferences.Setting
 value = default_value
 
 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 80 of file preferences.py.

Constructor & Destructor Documentation

◆ __init__()

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

Definition at line 83 of file preferences.py.

83 def __init__(self, default_value: str, choices: Iterable[str], locked=False):
84 super().__init__(default_value, locked)
85 self.choices = choices
86 self._validate_selection(self.value)
87

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 88 of file preferences.py.

88 def _validate_selection(self, selection: str):
89 if selection not in self.choices:
90 raise ValidationException('Invalid value: "{0}"'.format(selection))
91

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 92 of file preferences.py.

92 def parse(self, data: str):
93 """Parse and validate ``data`` and store the result at ``self.value``"""
94 self._validate_selection(data)
95 self.value = data
96
97

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: