summaryrefslogtreecommitdiff
path: root/searx/utils.py
diff options
context:
space:
mode:
authorAlexandre Flament <alex@al-f.net>2020-10-26 19:25:28 +0100
committerAlexandre Flament <alex@al-f.net>2020-10-28 08:09:25 +0100
commitca593728af10751fb0a313e2219e9091434d1035 (patch)
tree32d50695201e2b787e3987b9727983fdcff82295 /searx/utils.py
parent382fded6651c16754d91411f806e8fe390f005e5 (diff)
downloadsearxng-ca593728af10751fb0a313e2219e9091434d1035.tar.gz
searxng-ca593728af10751fb0a313e2219e9091434d1035.zip
[mod] duckduckgo_definitions: display only user friendly attributes / URL
various bug fixes
Diffstat (limited to 'searx/utils.py')
-rw-r--r--searx/utils.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/searx/utils.py b/searx/utils.py
index 1c10585cf..9e43c67f0 100644
--- a/searx/utils.py
+++ b/searx/utils.py
@@ -481,6 +481,16 @@ def ecma_unescape(s):
return s
+def get_string_replaces_function(replaces):
+ rep = {re.escape(k): v for k, v in replaces.items()}
+ pattern = re.compile("|".join(rep.keys()))
+
+ def f(text):
+ return pattern.sub(lambda m: rep[re.escape(m.group(0))], text)
+
+ return f
+
+
def get_engine_from_settings(name):
"""Return engine configuration from settings.yml of a given engine name"""