summaryrefslogtreecommitdiff
path: root/searx/utils.py
diff options
context:
space:
mode:
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"""