summaryrefslogtreecommitdiff
path: root/searx/plugins/calculator.py
diff options
context:
space:
mode:
authorBnyro <bnyro@tutanota.com>2025-06-26 15:13:42 +0200
committerMarkus Heiser <markus.heiser@darmarIT.de>2025-07-03 13:57:31 +0200
commita0fca8c21b1985474b438e1668f20e40d1d6d25b (patch)
treedd9883b5cb05fa574fcdebde9b77f0c3ec778b40 /searx/plugins/calculator.py
parent39c50dc013944a0a27b4354c23f406956ac45971 (diff)
[feat] calculator: add some operations (mod, shifts, bitwise and/or)
Diffstat (limited to 'searx/plugins/calculator.py')
-rw-r--r--searx/plugins/calculator.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/searx/plugins/calculator.py b/searx/plugins/calculator.py
index 0b6a0838e..65866ea48 100644
--- a/searx/plugins/calculator.py
+++ b/searx/plugins/calculator.py
@@ -1,6 +1,5 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
-"""Calculate mathematical expressions using :py:obj:`ast.parse` (mode="eval").
-"""
+"""Calculate mathematical expressions using :py:obj:`ast.parse` (mode="eval")."""
from __future__ import annotations
import typing
@@ -93,7 +92,12 @@ operators: dict[type, typing.Callable] = {
ast.Div: operator.truediv,
ast.Pow: operator.pow,
ast.BitXor: operator.xor,
+ ast.BitOr: operator.or_,
+ ast.BitAnd: operator.and_,
ast.USub: operator.neg,
+ ast.RShift: operator.rshift,
+ ast.LShift: operator.lshift,
+ ast.Mod: operator.mod,
}
# with multiprocessing.get_context("fork") we are ready for Py3.14 (by emulating