SearXNG is a free internet metasearch engine which aggregates results from various search services and databases. Users are neither tracked nor profiled.
Python bingbravedegoogleduckduckgogooglemetasearchprivacypythonqwantsearchsearch-enginesearxsearxngstartpageyahoo
[fix] pylint: use "raise ... from ..."
Alexandre Flament3f8ebf70b193
diff --git a/searx/engines/elasticsearch.py b/searx/engines/elasticsearch.pyindex 081736c1c..0e2d35756 100644--- a/searx/engines/elasticsearch.py+++ b/searx/engines/elasticsearch.py@@ -46,8 +46,8 @@ def _match_query(query):try:key, value = query.split(':')- except:- raise ValueError('query format must be "key:value"')+ except Exception as e:+ raise ValueError('query format must be "key:value"') from ereturn {"query": {"match": {key: {'query': value}}}}@@ -71,8 +71,8 @@ def _term_query(query):try:key, value = query.split(':')- except:- raise ValueError('query format must be key:value')+ except Exception as e:+ raise ValueError('query format must be key:value') from ereturn {'query': {'term': {key: value}}}@@ -86,8 +86,8 @@ def _terms_query(query):try:key, values = query.split(':')- except:- raise ValueError('query format must be key:value1,value2')+ except Exception as e:+ raise ValueError('query format must be key:value1,value2') from ereturn {'query': {'terms': {key: values.split(',')}}}diff --git a/searx/settings_loader.py b/searx/settings_loader.pyindex 5dbeb4a9a..e7126aa89 100644--- a/searx/settings_loader.py+++ b/searx/settings_loader.py@@ -24,9 +24,9 @@ def load_yaml(file_name):with open(file_name, 'r', encoding='utf-8') as settings_yaml:return yaml.safe_load(settings_yaml)except IOError as e:- raise SearxSettingsException(e, file_name)+ raise SearxSettingsException(e, file_name) from eexcept yaml.YAMLError as e:- raise SearxSettingsException(e, file_name)+ raise SearxSettingsException(e, file_name) from edef get_default_settings_path():diff --git a/searx/utils.py b/searx/utils.pyindex 057e9d004..3172ad8f3 100644--- a/searx/utils.py+++ b/searx/utils.py@@ -522,7 +522,7 @@ def get_xpath(xpath_spec):try:result = XPath(xpath_spec)except XPathSyntaxError as e:- raise SearxXPathSyntaxException(xpath_spec, str(e.msg))+ raise SearxXPathSyntaxException(xpath_spec, str(e.msg)) from expath_cache[xpath_spec] = resultreturn result@@ -553,7 +553,7 @@ def eval_xpath(element, xpath_spec):return xpath(element)except XPathError as e:arg = ' '.join([str(i) for i in e.args])- raise SearxEngineXPathException(xpath_spec, arg)+ raise SearxEngineXPathException(xpath_spec, arg) from edef eval_xpath_list(element, xpath_spec, min_len=None):diff --git a/searx/webadapter.py b/searx/webadapter.pyindex 0ad82c62c..ca2604c3e 100644--- a/searx/webadapter.py+++ b/searx/webadapter.py@@ -105,8 +105,8 @@ def parse_timeout(form: Dict[str, str], raw_text_query: RawTextQuery) -> Optionareturn Nonetry:return float(timeout_limit)- except ValueError:- raise SearxParameterException('timeout_limit', timeout_limit)+ except ValueError as e:+ raise SearxParameterException('timeout_limit', timeout_limit) from edef parse_category_form(query_categories: List[str], name: str, value: str) -> None: