SearXNG is a free internet metasearch engine which aggregates results from various search services and databases. Users are neither tracked nor profiled.
Python bingbravedegoogleduckduckgogooglemetasearchprivacypythonqwantsearchsearch-enginesearxsearxngstartpageyahoo
[mod] webutils.py: remove dead code
Alexandre Flament7d4834ac4dd7
diff --git a/searx/webutils.py b/searx/webutils.pyindex 737e5a82f..11a101806 100644--- a/searx/webutils.py+++ b/searx/webutils.py@@ -77,14 +77,7 @@ def get_result_templates(templates_path):def new_hmac(secret_key, url):- try:- secret_key_bytes = bytes(secret_key, 'utf-8')- except TypeError as err:- if isinstance(secret_key, bytes):- secret_key_bytes = secret_key- else:- raise err- return hmac.new(secret_key_bytes, url, hashlib.sha256).hexdigest()+ return hmac.new(secret_key.encode(), url, hashlib.sha256).hexdigest()def prettify_url(url, max_length=74):diff --git a/tests/unit/test_webutils.py b/tests/unit/test_webutils.pyindex 2b7c6fe5a..31a0f86ce 100644--- a/tests/unit/test_webutils.py+++ b/tests/unit/test_webutils.py@@ -78,10 +78,12 @@ class TestUnicodeWriter(SearxTestCase):class TestNewHmac(SearxTestCase):def test_bytes(self):- for secret_key in ['secret', b'secret', 1]:- if secret_key == 1:- with self.assertRaises(TypeError):- webutils.new_hmac(secret_key, b'http://example.com')- continue- res = webutils.new_hmac(secret_key, b'http://example.com')- self.assertEqual(res, '23e2baa2404012a5cc8e4a18b4aabf0dde4cb9b56f679ddc0fd6d7c24339d819')+ data = b'http://example.com'+ with self.assertRaises(AttributeError):+ webutils.new_hmac(b'secret', data)++ with self.assertRaises(AttributeError):+ webutils.new_hmac(1, data)++ res = webutils.new_hmac('secret', data)+ self.assertEqual(res, '23e2baa2404012a5cc8e4a18b4aabf0dde4cb9b56f679ddc0fd6d7c24339d819')