diff options
| author | Martin Fischer <martin@push-f.com> | 2021-12-28 16:12:54 +0100 |
|---|---|---|
| committer | Martin Fischer <martin@push-f.com> | 2022-01-05 11:03:44 +0100 |
| commit | ab90e2ac49778153409397d4a2c34e9051963a0f (patch) | |
| tree | 811c93fa0466b0e3796a5032a5bdfea8a665b285 /searx/engines/__init__.py | |
| parent | 4ac6b5d32dc60ce410eb7166722c86e82f8c937c (diff) | |
[enh] show categories not in any tab category in "Other" preferences tab
Previously we didn't have a good place to put search engines that don't
fit into any of the tab categories. This commit automatically puts
search engines that don't belong to any tab category in an "other"
category, that is only displayed in the user preferences (and not above
search results).
Diffstat (limited to 'searx/engines/__init__.py')
| -rw-r--r-- | searx/engines/__init__.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/searx/engines/__init__.py b/searx/engines/__init__.py index 8d49bae8a..9472186bf 100644 --- a/searx/engines/__init__.py +++ b/searx/engines/__init__.py @@ -45,6 +45,9 @@ ENGINE_DEFAULT_ARGS = { "display_error_messages": True, "tokens": [], } +# set automatically when an engine does not have any tab category +OTHER_CATEGORY = 'other' + """Defaults for the namespace of an engine module, see :py:func:`load_engine`""" categories = {'general': []} @@ -114,6 +117,9 @@ def load_engine(engine_data): set_loggers(engine, engine_name) + if not any(cat in settings['categories_as_tabs'] for cat in engine.categories): + engine.categories.append(OTHER_CATEGORY) + return engine @@ -274,7 +280,7 @@ def group_engines_in_tab(engines): # pylint: disable=redefined-outer-name return (group[0] == DEFAULT_GROUP_NAME, group[0].lower()) def get_group(eng): - non_tab_engines = [c for c in eng.categories if c not in settings['categories_as_tabs']] + non_tab_engines = [c for c in eng.categories if c not in settings['categories_as_tabs'] + [OTHER_CATEGORY]] return non_tab_engines[0] if len(non_tab_engines) > 0 else DEFAULT_GROUP_NAME return [ |