.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 (settings, schema, path_list)
 
 settings_set_defaults (settings)
 

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()
 
dict SCHEMA
 

Detailed Description

Implementation of the default settings.

Function Documentation

◆ apply_schema()

searx.settings_defaults.apply_schema ( settings,
schema,
path_list )

Definition at line 119 of file settings_defaults.py.

119def apply_schema(settings, schema, path_list):
120 error = False
121 for key, value in schema.items():
122 if isinstance(value, SettingsValue):
123 try:
124 settings[key] = value(settings.get(key, _UNDEFINED))
125 except Exception as e: # pylint: disable=broad-except
126 # don't stop now: check other values
127 logger.error('%s: %s', '.'.join([*path_list, key]), e)
128 error = True
129 elif isinstance(value, dict):
130 error = error or apply_schema(settings.setdefault(key, {}), schema[key], [*path_list, key])
131 else:
132 settings.setdefault(key, value)
133 if len(path_list) == 0 and error:
134 raise ValueError('Invalid settings.yml')
135 return error
136
137

References searx.settings_defaults.apply_schema().

Referenced by searx.settings_defaults.apply_schema(), and searx.settings_defaults.settings_set_defaults().

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

◆ settings_set_defaults()

searx.settings_defaults.settings_set_defaults ( settings)

Definition at line 248 of file settings_defaults.py.

248def settings_set_defaults(settings):
249 apply_schema(settings, SCHEMA, [])
250 return settings

References searx.settings_defaults.apply_schema().

+ Here is the call graph for this function:

Variable Documentation

◆ _UNDEFINED

searx.settings_defaults._UNDEFINED = object()
protected

Definition at line 42 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 22 of file settings_defaults.py.

◆ logger

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

Definition at line 18 of file settings_defaults.py.

◆ OUTPUT_FORMATS

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

Definition at line 19 of file settings_defaults.py.

◆ SCHEMA

dict searx.settings_defaults.SCHEMA

Definition at line 138 of file settings_defaults.py.

◆ searx_dir

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

Definition at line 16 of file settings_defaults.py.

◆ SIMPLE_STYLE

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

Definition at line 21 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 34 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 20 of file settings_defaults.py.