.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
 get_value (self)
 
 save (self, str name, flask.Response resp)
 

Public Attributes

 choices = choices
 
 value
 
- 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 77 of file preferences.py.

Constructor & Destructor Documentation

◆ __init__()

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

Reimplemented from searx.preferences.Setting.

Definition at line 80 of file preferences.py.

80 def __init__(self, default_value: str, choices: Iterable[str], locked=False):
81 super().__init__(default_value, locked)
82 self.choices = choices
83 self._validate_selection(self.value)
84

References searx.preferences.EnumStringSetting.__init__().

Referenced by searx.preferences.EnumStringSetting.__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 85 of file preferences.py.

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

References searx.preferences.BooleanChoices.choices, searx.preferences.EnumStringSetting.choices, searx.preferences.MultipleChoiceSetting.choices, searx.preferences.SearchLanguageSetting.choices, and searx.format.

Referenced by searx.preferences.EnumStringSetting.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 89 of file preferences.py.

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

References searx.preferences.EnumStringSetting._validate_selection(), searx.preferences.SearchLanguageSetting._validate_selection(), searx.preferences.BooleanSetting.value, searx.preferences.EnumStringSetting.value, searx.preferences.MapSetting.value, searx.preferences.MultipleChoiceSetting.value, searx.preferences.SearchLanguageSetting.value, and searx.preferences.Setting.value.

+ Here is the call graph for this function:

Member Data Documentation

◆ choices

◆ value


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