From accc1c10322d9ee34b4aafe6e7a5dfbc785b5624 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sandro=20J=C3=A4ckel?= Date: Tue, 11 Jun 2024 14:39:42 +0200 Subject: [PATCH] [fix] setup.py - packaging for 'answerers' to build a valid package Fix installing answerers when installing SearXNG through a wheel [1]. These files have been missed in commit d72fa99b. Here is what have been tested: $ make clean py.build ... $ python -m venv test123 $ . ./test123/bin/activate (test123) $ pip install dist/searxng-2024*-py3-none-any.whl (test123) $ SEARXNG_DEBUG=1 searxng-run [1] https://github.com/searxng/searxng/pull/3045#issuecomment-1961767861 --- searx/answerers/random/__init__.py | 2 ++ searx/answerers/random/answerer.py | 1 + searx/answerers/statistics/__init__.py | 2 ++ searx/answerers/statistics/answerer.py | 20 +++++++++++--------- 4 files changed, 16 insertions(+), 9 deletions(-) create mode 100644 searx/answerers/random/__init__.py create mode 100644 searx/answerers/statistics/__init__.py diff --git a/searx/answerers/random/__init__.py b/searx/answerers/random/__init__.py new file mode 100644 index 000000000..9ed59c825 --- /dev/null +++ b/searx/answerers/random/__init__.py @@ -0,0 +1,2 @@ +# SPDX-License-Identifier: AGPL-3.0-or-later +# pylint: disable=missing-module-docstring diff --git a/searx/answerers/random/answerer.py b/searx/answerers/random/answerer.py index efdce0407..66147fa54 100644 --- a/searx/answerers/random/answerer.py +++ b/searx/answerers/random/answerer.py @@ -1,4 +1,5 @@ # SPDX-License-Identifier: AGPL-3.0-or-later +# pylint: disable=missing-module-docstring import hashlib import random diff --git a/searx/answerers/statistics/__init__.py b/searx/answerers/statistics/__init__.py new file mode 100644 index 000000000..9ed59c825 --- /dev/null +++ b/searx/answerers/statistics/__init__.py @@ -0,0 +1,2 @@ +# SPDX-License-Identifier: AGPL-3.0-or-later +# pylint: disable=missing-module-docstring diff --git a/searx/answerers/statistics/answerer.py b/searx/answerers/statistics/answerer.py index 3c38243de..b0a5ddba5 100644 --- a/searx/answerers/statistics/answerer.py +++ b/searx/answerers/statistics/answerer.py @@ -1,4 +1,6 @@ # SPDX-License-Identifier: AGPL-3.0-or-later +# pylint: disable=missing-module-docstring + from functools import reduce from operator import mul @@ -18,27 +20,27 @@ def answer(query): try: args = list(map(float, parts[1:])) - except: + except: # pylint: disable=bare-except return [] func = parts[0] - answer = None + _answer = None if func == 'min': - answer = min(args) + _answer = min(args) elif func == 'max': - answer = max(args) + _answer = max(args) elif func == 'avg': - answer = sum(args) / len(args) + _answer = sum(args) / len(args) elif func == 'sum': - answer = sum(args) + _answer = sum(args) elif func == 'prod': - answer = reduce(mul, args, 1) + _answer = reduce(mul, args, 1) - if answer is None: + if _answer is None: return [] - return [{'answer': str(answer)}] + return [{'answer': str(_answer)}] # required answerer function