.oO SearXNG Developer Documentation Oo.
Loading...
Searching...
No Matches
searx.settings_defaults Namespace Reference

Classes

class  SettingsBytesValue
class  SettingsDirectoryValue
class  SettingSublistValue
class  SettingsValue

Functions

 apply_schema (dict[str, t.Any] settings, dict[str, t.Any] schema, list[str] path_list)

Variables

 searx_dir = abspath(dirname(__file__))
 logger = logging.getLogger('searx')
list OUTPUT_FORMATS = ['html', 'csv', 'json', 'rss']
list SXNG_LOCALE_TAGS = ['all', 'auto'] + list(l[0] for l in sxng_locales)
tuple SIMPLE_STYLE = ('auto', 'light', 'dark', 'black')
dict CATEGORIES_AS_TABS
dict STR_TO_BOOL
 _UNDEFINED = object()
tuple TypeDefinition
TypeDefinitionArg = type | TypeDefinition
dict SCHEMA

Detailed Description

Implementation of the default settings.

Function Documentation

◆ apply_schema()

searx.settings_defaults.apply_schema ( dict[str, t.Any] settings,
dict[str, t.Any] schema,
list[str] path_list )

Definition at line 140 of file settings_defaults.py.

140def apply_schema(settings: dict[str, t.Any], schema: dict[str, t.Any], path_list: list[str]):
141 error = False
142 for key, value in schema.items():
143 if isinstance(value, SettingsValue):
144 try:
145 settings[key] = value(settings.get(key, _UNDEFINED))
146 except Exception as e: # pylint: disable=broad-except
147 # don't stop now: check other values
148 logger.error('%s: %s', '.'.join([*path_list, key]), e)
149 error = True
150 elif isinstance(value, dict):
151 error = error or apply_schema(settings.setdefault(key, {}), schema[key], [*path_list, key])
152 else:
153 settings.setdefault(key, value)
154 if len(path_list) == 0 and error:
155 raise ValueError('Invalid settings.yml')
156 return error
157
158

References apply_schema().

Referenced by apply_schema().

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

Variable Documentation

◆ _UNDEFINED

searx.settings_defaults._UNDEFINED = object()
protected

Definition at line 44 of file settings_defaults.py.

◆ CATEGORIES_AS_TABS

dict searx.settings_defaults.CATEGORIES_AS_TABS
Initial value:
1= {
2 'general': {},
3 'images': {},
4 'videos': {},
5 'news': {},
6 'map': {},
7 'music': {},
8 'it': {},
9 'science': {},
10 'files': {},
11 'social media': {},
12}

Definition at line 24 of file settings_defaults.py.

◆ logger

searx.settings_defaults.logger = logging.getLogger('searx')

Definition at line 20 of file settings_defaults.py.

◆ OUTPUT_FORMATS

list searx.settings_defaults.OUTPUT_FORMATS = ['html', 'csv', 'json', 'rss']

Definition at line 21 of file settings_defaults.py.

◆ SCHEMA

dict searx.settings_defaults.SCHEMA

Definition at line 159 of file settings_defaults.py.

◆ searx_dir

searx.settings_defaults.searx_dir = abspath(dirname(__file__))

Definition at line 18 of file settings_defaults.py.

◆ SIMPLE_STYLE

tuple searx.settings_defaults.SIMPLE_STYLE = ('auto', 'light', 'dark', 'black')

Definition at line 23 of file settings_defaults.py.

◆ STR_TO_BOOL

dict searx.settings_defaults.STR_TO_BOOL
Initial value:
1= {
2 '0': False,
3 'false': False,
4 'off': False,
5 '1': True,
6 'true': True,
7 'on': True,
8}

Definition at line 36 of file settings_defaults.py.

◆ SXNG_LOCALE_TAGS

list searx.settings_defaults.SXNG_LOCALE_TAGS = ['all', 'auto'] + list(l[0] for l in sxng_locales)

Definition at line 22 of file settings_defaults.py.

◆ TypeDefinition

tuple searx.settings_defaults.TypeDefinition
Initial value:
1= ( # pylint: disable=invalid-name
2 tuple[None, bool, type]
3 | tuple[None, type, type]
4 | tuple[None, type]
5 | tuple[bool, type]
6 | tuple[type, type]
7 | tuple[type]
8 | tuple[str | int, ...]
9)

Definition at line 49 of file settings_defaults.py.

◆ TypeDefinitionArg

t searx.settings_defaults.TypeDefinitionArg = type | TypeDefinition

Definition at line 59 of file settings_defaults.py.