mirror of
https://github.com/searxng/searxng
synced 2024-01-01 19:24:07 +01:00
[enh] introduce Engine class
Previously engines were defined in modules, which where then stapled with logger, supported_languages & language_aliases via monkey patching in searx/engines/__init__.py. Monkey patching is obviously a bad practice since it confuses humans as well as static type checkers. But there were more problems: * there were no type hints for the method input and output types * the request method did not even make a clear distinction between input and output (abusing a single "params" dictionary for both) This commit introduces a new class-based architecture for engines, in a backwards-compatiable manner: allowing old-style module engines to be used along witn new-style class-based engines.
This commit is contained in:
parent
73e71508e4
commit
5dd28ff04b
5 changed files with 147 additions and 7 deletions
|
|
@ -48,12 +48,14 @@ Explanation of the :ref:`general engine configuration` shown in the table
|
|||
|
||||
{% for mod in engines %}
|
||||
|
||||
{% set mod_name = mod['__name__'] or mod.__module__ %}
|
||||
|
||||
* - `{{mod.name}} <{{mod.about and mod.about.website}}>`_
|
||||
- ``!{{mod.shortcut}}``
|
||||
- {%- if 'searx.engines.' + mod.__name__ in documented_modules %}
|
||||
:py:mod:`~searx.engines.{{mod.__name__}}`
|
||||
- {%- if 'searx.engines.' + mod_name in documented_modules %}
|
||||
:py:mod:`~searx.engines.{{mod_name}}`
|
||||
{%- else %}
|
||||
:origin:`{{mod.__name__}} <searx/engines/{{mod.__name__}}.py>`
|
||||
:origin:`{{mod_name}} <searx/engines/{{mod_name}}.py>`
|
||||
{%- endif %}
|
||||
- {{(mod.disabled and "y") or ""}}
|
||||
{%- if mod.about and mod.about.language %}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue