Merge pull request #634 from not-my-profile/powered-by

Introduce `categories_as_tabs` & group engines in tabs
This commit is contained in:
Alexandre Flament 2022-01-06 09:22:02 +01:00 committed by GitHub
commit aedd6279b3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
44 changed files with 247 additions and 105 deletions

View file

@ -13,6 +13,7 @@ usage::
import sys
import copy
from typing import List
from os.path import realpath, dirname
from babel.localedata import locale_identifiers
@ -44,7 +45,29 @@ ENGINE_DEFAULT_ARGS = {
"display_error_messages": True,
"tokens": [],
}
"""Defaults for the namespace of an engine module, see :py:func:`load_engine`"""
# set automatically when an engine does not have any tab category
OTHER_CATEGORY = 'other'
class Engine: # pylint: disable=too-few-public-methods
"""This class is currently never initialized and only used for type hinting."""
name: str
engine: str
shortcut: str
categories: List[str]
supported_languages: List[str]
about: dict
inactive: bool
disabled: bool
language_support: bool
paging: bool
safesearch: bool
time_range_support: bool
timeout: float
# Defaults for the namespace of an engine module, see :py:func:`load_engine``
categories = {'general': []}
engines = {}
@ -113,6 +136,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
@ -138,6 +164,8 @@ def update_engine_attributes(engine, engine_data):
if isinstance(param_value, str):
param_value = list(map(str.strip, param_value.split(',')))
engine.categories = param_value
elif hasattr(engine, 'about') and param_name == 'about':
engine.about = {**engine.about, **engine_data['about']}
else:
setattr(engine, param_name, param_value)

View file

@ -24,7 +24,7 @@ about = {
}
# engine dependent config
categories = ['files']
categories = ['files', 'apps']
paging = True
time_range_support = False

View file

@ -20,7 +20,7 @@ about = {
}
# engine dependent config
categories = ['it']
categories = ['it', 'software wikis']
paging = True
base_url = 'https://wiki.archlinux.org'

View file

@ -20,7 +20,7 @@ about = {
}
# engine dependent config
categories = ['general']
categories = ['general', 'web']
paging = True
time_range_support = False
safesearch = False

View file

@ -27,7 +27,7 @@ about = {
}
# engine dependent config
categories = ['images']
categories = ['images', 'web']
paging = True
safesearch = True
time_range_support = True

View file

@ -26,7 +26,7 @@ about = {
"results": 'HTML',
}
categories = ['videos']
categories = ['videos', 'web']
paging = True
safesearch = True
time_range_support = True

View file

@ -27,7 +27,7 @@ about = {
}
# engine dependent config
categories = ['general']
categories = ['general', 'web']
paging = True
supported_languages_url = 'https://duckduckgo.com/util/u588.js'
time_range_support = True

View file

@ -27,7 +27,7 @@ about = {
}
# engine dependent config
categories = ['images']
categories = ['images', 'web']
paging = True
safesearch = True

View file

@ -19,7 +19,7 @@ about = {
"language": 'de',
}
categories = ['general']
categories = ['dictionaries']
paging = True
# search-url

View file

@ -17,7 +17,7 @@ about = {
"results": 'HTML',
}
categories = ['general']
categories = ['general', 'web']
paging = False
safesearch = True

View file

@ -18,7 +18,7 @@ about = {
}
# engine dependent config
categories = ['files']
categories = ['files', 'apps']
paging = True
# search-url

View file

@ -20,7 +20,7 @@ about = {
}
# engine dependent config
categories = ['music']
categories = ['music', 'lyrics']
paging = True
page_size = 5

View file

@ -18,7 +18,7 @@ about = {
}
# engine dependent config
categories = ['it']
categories = ['it', 'software wikis']
paging = True
base_url = 'https://wiki.gentoo.org'

View file

@ -22,7 +22,7 @@ about = {
}
# engine dependent config
categories = ['general']
categories = ['general', 'web']
# gigablast's pagination is totally damaged, don't use it
paging = False
safesearch = True

View file

@ -17,7 +17,7 @@ about = {
}
# engine dependent config
categories = ['it']
categories = ['it', 'repos']
# search-url
search_url = 'https://api.github.com/search/repositories?sort=stars&order=desc&{query}' # noqa

View file

@ -41,7 +41,7 @@ about = {
}
# engine dependent config
categories = ['general']
categories = ['general', 'web']
paging = True
time_range_support = True
safesearch = True

View file

@ -45,7 +45,7 @@ about = {
}
# engine dependent config
categories = ['images']
categories = ['images', 'web']
paging = False
use_locale_domain = True
time_range_support = True

View file

@ -54,7 +54,7 @@ about = {
# engine dependent config
categories = ['videos']
categories = ['videos', 'web']
paging = False
language_support = True
use_locale_domain = True

View file

@ -27,9 +27,7 @@ about = {
"results": 'HTML',
}
categories = [
'general',
]
categories = []
paging = False
# suggestion_url = "https://sg.media-imdb.com/suggestion/{letter}/{query}.json"

View file

@ -25,6 +25,7 @@ about = {
"language": "cz",
}
categories = ['general', 'web']
base_url = 'https://search.seznam.cz/'

View file

@ -21,7 +21,7 @@ about = {
"language": 'pl',
}
categories = ['general']
categories = ['dictionaries']
paging = False
URL = 'https://sjp.pwn.pl'

View file

@ -23,7 +23,7 @@ about = {
}
# engine dependent config
categories = ['general']
categories = ['general', 'web']
# there is a mechanism to block "bot" search
# (probably the parameter qid), require
# storing of qid's between mulitble search-calls

View file

@ -14,7 +14,7 @@ about = {
}
engine_type = 'online_dictionary'
categories = ['general']
categories = ['dictionaries']
url = 'https://api.mymemory.translated.net/get?q={query}&langpair={from_lang}|{to_lang}{key}'
web_url = 'https://mymemory.translated.net/en/{from_lang}/{to_lang}/{query}'
weight = 100

View file

@ -31,7 +31,7 @@ about = {
}
# engine dependent config
categories = ['general']
categories = ['general', 'web']
paging = True
time_range_support = True
supported_languages_url = 'https://search.yahoo.com/preferences/languages'