summaryrefslogtreecommitdiff
path: root/searx
diff options
context:
space:
mode:
authorMarkus Heiser <markus.heiser@darmarit.de>2024-10-15 17:26:59 +0200
committerMarkus Heiser <markus.heiser@darmarIT.de>2024-10-26 15:59:42 +0200
commite08ff05fffe0bdae67af5fd48ed35716fb8cb853 (patch)
treef0562fd450a1e97ce9aee04e70069932d70e967c /searx
parenta3921b5ed7e70e6355763569970076e9038f3106 (diff)
downloadsearxng-e08ff05fffe0bdae67af5fd48ed35716fb8cb853.tar.gz
searxng-e08ff05fffe0bdae67af5fd48ed35716fb8cb853.zip
[fix] add missing tomli to the requirements.txt
Package ``tomli`` is needed for py < 3.11, BTW remove the no longer needed pytomlpp package. Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
Diffstat (limited to 'searx')
-rw-r--r--searx/botdetection/config.py27
1 files changed, 4 insertions, 23 deletions
diff --git a/searx/botdetection/config.py b/searx/botdetection/config.py
index 147104205..2a982ba64 100644
--- a/searx/botdetection/config.py
+++ b/searx/botdetection/config.py
@@ -14,17 +14,7 @@ import typing
import logging
import pathlib
-try:
- import tomllib
-
- pytomlpp = None
- USE_TOMLLIB = True
-except ImportError:
- import pytomlpp
-
- tomllib = None
- USE_TOMLLIB = False
-
+from ..compat import tomllib
__all__ = ['Config', 'UNSET', 'SchemaIssue']
@@ -183,19 +173,10 @@ class Config:
def toml_load(file_name):
- if USE_TOMLLIB:
- # Python >= 3.11
- try:
- with open(file_name, "rb") as f:
- return tomllib.load(f)
- except tomllib.TOMLDecodeError as exc:
- msg = str(exc).replace('\t', '').replace('\n', ' ')
- log.error("%s: %s", file_name, msg)
- raise
- # fallback to pytomlpp for Python < 3.11
try:
- return pytomlpp.load(file_name)
- except pytomlpp.DecodeError as exc:
+ with open(file_name, "rb") as f:
+ return tomllib.load(f)
+ except tomllib.TOMLDecodeError as exc:
msg = str(exc).replace('\t', '').replace('\n', ' ')
log.error("%s: %s", file_name, msg)
raise