This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# SPDX-License-Identifier: AGPL-3.0-or-later
"""Calculate mathematical expressions using ack#eval
"""
importdecimal
importre
importsys
importsubprocess
frompathlibimportPath
importflask
importbabel
fromflask_babelimportgettext
fromsearx.pluginsimportlogger
name="Basic Calculator"
description=gettext("Calculate mathematical expressions via the search bar")
default_on=True
preference_section='general'
plugin_id='calculator'
logger=logger.getChild(plugin_id)
defcall_calculator(query_py_formatted,timeout):
# see https://docs.python.org/3/using/cmdline.html
# -S Disable the import of the module site and the site-dependent manipulations
# of sys.path that it entails. Also disable these manipulations if site is
# explicitly imported later (call site.main() if you want them to be triggered).
# -I Run Python in isolated mode. This also implies -E, -P and -s options.
# -E Ignore all PYTHON* environment variables, e.g. PYTHONPATH and PYTHONHOME, that might be set.
# -P Don’t prepend a potentially unsafe path to sys.path
# -s Don’t add the user site-packages directory to sys.path.