.oO SearXNG Developer Documentation Oo.
|
Functions | |
load_yaml (str|Path file_name) | |
dict | get_yaml_cfg (str|Path file_name) |
Path|None | get_user_cfg_folder () |
update_dict (default_dict, user_dict) | |
update_settings (dict default_settings, dict user_settings) | |
is_use_default_settings (user_settings) | |
tuple[dict, str] | load_settings (load_user_settings=True) |
Variables | |
searx_dir = os.path.abspath(os.path.dirname(__file__)) | |
SETTINGS_YAML = Path("settings.yml") | |
DEFAULT_SETTINGS_FILE = Path(searx_dir) / SETTINGS_YAML | |
Implementations for loading configurations from YAML files. This essentially includes the configuration of the (:ref:`SearXNG appl <searxng settings.yml>`) server. The default configuration for the application server is loaded from the :origin:`DEFAULT_SETTINGS_FILE <searx/settings.yml>`. This default configuration can be completely replaced or :ref:`customized individually <use_default_settings.yml>` 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 :py:obj:`get_user_cfg_folder` function. - By default, local configurations are expected in folder ``/etc/searxng`` from where applications can load them with the :py:obj:`get_yaml_cfg` function. - By default, customized :ref:`SearXNG appl <searxng settings.yml>` settings are expected in a file named ``settings.yml``.
Path | None searx.settings_loader.get_user_cfg_folder | ( | ) |
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 :ref:`SearXNG appl <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 :ref:`SearXNG appl <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 :ref:`SearXNG appl <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 :py:obj:`EnvironmentError` is raised.
Definition at line 64 of file settings_loader.py.
Referenced by searx.settings_loader.get_yaml_cfg(), and searx.settings_loader.load_settings().
dict searx.settings_loader.get_yaml_cfg | ( | str | Path | file_name | ) |
Shortcut to load a YAML config from a file, located in the - :py:obj:`get_user_cfg_folder` or - in the ``searx`` folder of the SearXNG installation
Definition at line 49 of file settings_loader.py.
References searx.settings_loader.get_user_cfg_folder(), and searx.settings_loader.load_yaml().
searx.settings_loader.is_use_default_settings | ( | user_settings | ) |
Definition at line 176 of file settings_loader.py.
Referenced by searx.settings_loader.load_settings().
tuple[dict, str] searx.settings_loader.load_settings | ( | load_user_settings = True | ) |
Function for loading the settings of the SearXNG application (:ref:`settings.yml <searxng settings.yml>`).
Definition at line 188 of file settings_loader.py.
References searx.settings_loader.get_user_cfg_folder(), searx.settings_loader.is_use_default_settings(), searx.settings_loader.load_yaml(), and searx.settings_loader.update_settings().
searx.settings_loader.load_yaml | ( | str | Path | file_name | ) |
Load YAML config from a file.
Definition at line 38 of file settings_loader.py.
Referenced by searx.settings_loader.get_yaml_cfg(), and searx.settings_loader.load_settings().
searx.settings_loader.update_dict | ( | default_dict, | |
user_dict ) |
Definition at line 116 of file settings_loader.py.
References searx.settings_loader.update_dict().
Referenced by searx.settings_loader.update_dict(), and searx.settings_loader.update_settings().
searx.settings_loader.update_settings | ( | dict | default_settings, |
dict | user_settings ) |
Definition at line 125 of file settings_loader.py.
References searx.settings_loader.update_dict().
Referenced by searx.settings_loader.load_settings().
searx.settings_loader.DEFAULT_SETTINGS_FILE = Path(searx_dir) / SETTINGS_YAML |
Definition at line 34 of file settings_loader.py.
searx.settings_loader.searx_dir = os.path.abspath(os.path.dirname(__file__)) |
Definition at line 31 of file settings_loader.py.
searx.settings_loader.SETTINGS_YAML = Path("settings.yml") |
Definition at line 33 of file settings_loader.py.