Settings Loader
Implementations for loading configurations from YAML files. This essentially
includes the configuration of the (SearXNG appl)
server. The default configuration for the application server is loaded from the
. This default
configuration can be completely replaced or customized individually and the SEARXNG_SETTINGS_PATH environment
variable can be used to set the location from which the local customizations are
to be loaded. The rules used for this can be found in the
get_user_cfg_folder function.
- By default, local configurations are expected in folder
/etc/searxngfrom where applications can load them with theget_yaml_cfgfunction. - By default, customized SearXNG appl settings are
expected in a file named
settings.yml.
searx.settings_loader.DEFAULT_SETTINGS_FILE = PosixPath('/home/runner/work/searxng/searxng/searx/settings.yml') : The file with all the default settings.
searx.settings_loader.load_yaml(file_name: str | Path) → dict[str, dict[str, dict[str, JSONType] | list[JSONType] | str | int | float | bool | None] | list[dict[str, JSONType] | list[JSONType] | str | int | float | bool | None] | str | int | float | bool | None][source] : Load YAML config from a file.
searx.settings_loader.get_yaml_cfg(file_name: str | Path) → dict[str, dict[str, dict[str, JSONType] | list[JSONType] | str | int | float | bool | None] | list[dict[str, JSONType] | list[JSONType] | str | int | float | bool | None] | str | int | float | bool | None][source] : Shortcut to load a YAML config from a file, located in the
- [`get_user_cfg_folder`](#searx.settings_loader.get_user_cfg_folder) or
- in the `searx` folder of the SearXNG installation
searx.settings_loader.get_user_cfg_folder() → Path | None[source] : Returns folder where the local configurations are located.
1. If the `SEARXNG_SETTINGS_PATH` environment is set and points to a
folder (e.g. `/etc/mysxng/`), all local configurations are expected in
this folder. The settings of the [SearXNG appl](https://docs.searxng.org/admin/settings/index.html#searxng-settings-yml) then expected in `settings.yml`
(e.g. `/etc/mysxng/settings.yml`).
2. If the `SEARXNG_SETTINGS_PATH` environment is set and points to a file
(e.g. `/etc/mysxng/myinstance.yml`), this file contains the settings of
the [SearXNG appl](https://docs.searxng.org/admin/settings/index.html#searxng-settings-yml) and the folder
(e.g. `/etc/mysxng/`) is used for all other configurations.
This type (`SEARXNG_SETTINGS_PATH` points to a file) is suitable for
use cases in which different profiles of the [SearXNG appl](https://docs.searxng.org/admin/settings/index.html#searxng-settings-yml) are to be managed, such as in test scenarios.
3. If folder `/etc/searxng` exists, it is used.
In case none of the above path exists, `None` is returned. In case of
environment `SEARXNG_SETTINGS_PATH` is set, but the (folder or file) does
not exists, a [`EnvironmentError`](https://docs.python.org/3/builtins/exceptions.html#EnvironmentError) is raised.
searx.settings_loader.load_settings(load_user_settings: bool = True) → tuple[dict[str, dict[str, dict[str, JSONType] | list[JSONType] | str | int | float | bool | None] | list[dict[str, JSONType] | list[JSONType] | str | int | float | bool | None] | str | int | float | bool | None], str][source] : Function for loading the settings of the SearXNG application (settings.yml).
Copyright © SearXNG team
Made with Furo
