summaryrefslogtreecommitdiff
path: root/searx/settings_loader.py
AgeCommit message (Collapse)Author
2024-07-14[mod] revision of the settings_loaderMarkus Heiser
The intention of this PR is to modernize the settings_loader implementations. The concept is old (remember, this is partly from 2014), back then we only had one config file, meanwhile we have had a folder with config files for a very long time. Callers can now load a YAML configuration from this folder as follows :: settings_loader.get_yaml_cfg('my-config.yml') - BTW this is a fix of #3557. - Further the `existing_filename_or_none` construct dates back to times when there was not yet a `pathlib.Path` in all Python versions we supported in the past. - Typehints have been added wherever appropriate At the same time, this patch should also be downward compatible and not introduce a new environment variable. The localization of the folder with the configurations is further based on: SEARXNG_SETTINGS_PATH (wich defaults to /etc/searxng/settings.yml) Which means, the default config folder is `/etc/searxng/`. ATTENTION: intended functional changes! If SEARXNG_SETTINGS_PATH was set and pointed to a not existing file, the previous implementation silently loaded the default configuration. This behavior has been changed: if the file or folder does not exist, an EnvironmentError exception will be thrown in future. Closes: https://github.com/searxng/searxng/issues/3557 Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
2024-06-07[feat] hostname replace plugin: support for external list fileBnyro
2024-03-11[mod] pylint all files with one profile / drop PYLINT_SEARXNG_DISABLE_OPTIONMarkus Heiser
In the past, some files were tested with the standard profile, others with a profile in which most of the messages were switched off ... some files were not checked at all. - ``PYLINT_SEARXNG_DISABLE_OPTION`` has been abolished - the distinction ``# lint: pylint`` is no longer necessary - the pylint tasks have been reduced from three to two 1. ./searx/engines -> lint engines with additional builtins 2. ./searx ./searxng_extra ./tests -> lint all other python files Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
2023-09-18[fix] spellingjazzzooo
2023-04-03[fix] categories can't be removed from UI (categories_as_tabs)Markus Heiser
When using ``use_default_settings: true``, removing default categories from settings.yml will not remove them from the UI. The value ``categories_as_tabs`` is a dictionary type (a4c2cfb) and dictionary types are merged additive by ``settings_loader.update_settings()``. This patch replaces the default ``categories_as_tabs`` by the one from the ``user_settings``. Related: https://github.com/searxng/searxng/issues/1019#issuecomment-1193145654 Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
2022-09-27[fix] typos / reported by @kianmeng in searx PR-3366Markus Heiser
[PR-3366] https://github.com/searx/searx/pull/3366 Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
2022-08-28Remove usage of SEARX environment variablesAlexandre FLAMENT
2021-12-27[format.python] initial formatting of the python codeMarkus Heiser
This patch was generated by black [1]:: make format.python [1] https://github.com/psf/black Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
2021-10-11SearXNG: load /etc/searxng/settings.ymlAlexandre Flament
fall back to /etc/searx/setting.yml
2021-10-02SearXNG: environment variablesAlexandre Flament
2021-05-18[fix] unit test: don't load /etc/searx/settings.ymlAlexandre Flament
Add a new environment variable SEARX_DISABLE_ETC_SETTINGS to disable loading of /etc/searx/settings.yml unit tests: * set SEARX_DISABLE_ETC_SETTINGS to 1 * remove SEARX_SETTINGS_PATH if it exists
2021-04-05[fix] settings_loader.py - use update_dict only for mapping typesMarkus Heiser
I can't set `default_doi_resolver` in `settings.yml` if I'm using `use_default_settings`. Searx seems to try to interpret all settings at root level in `settings.yml` as dict, which is correct except for `default_doi_resolver` which is at root level and a string:: File "/usr/lib/python3.9/site-packages/searx/settings_loader.py", line 125, in load_settings update_settings(default_settings, user_settings) File "/usr/lib/python3.9/site-packages/searx/settings_loader.py", line 61, in update_settings update_dict(default_settings[k], v) File "/usr/lib/python3.9/site-packages/searx/settings_loader.py", line 48, in update_dict for k, v in user_dict.items(): AttributeError: 'str' object has no attribute 'items' Signed-off-by: Markus Heiser <markus@darmarit.de> Suggested-by: @0xhtml https://github.com/searx/searx/issues/2722#issuecomment-813391659
2020-12-20[fix] pylint: use "raise ... from ..."Alexandre Flament
2020-12-03[fix] settings_loader: don't crash when a key exists only in the user settingsAlexandre Flament
typical use case: result_proxy can be defined in the user settings, but are not defined the default settings.yml
2020-11-27[enh] settings.yml: add use_default_settings option (2nd version)Alexandre Flament