summaryrefslogtreecommitdiff
path: root/searx
diff options
context:
space:
mode:
authorMarkus Heiser <markus.heiser@darmarit.de>2021-12-27 09:16:03 +0100
committerMarkus Heiser <markus.heiser@darmarit.de>2021-12-27 09:16:03 +0100
commitfcdc2c2cd26e24c2aa3f064d93cee3e29dc2a30c (patch)
tree3e508c94d5ac69869aa69fc686cd54e02bfcad27 /searx
parentc849731eb1df23b8509a947fcc2807adb34dc730 (diff)
downloadsearxng-fcdc2c2cd26e24c2aa3f064d93cee3e29dc2a30c.tar.gz
searxng-fcdc2c2cd26e24c2aa3f064d93cee3e29dc2a30c.zip
[format.python] disable py code formatting for some hunks of code
Disable the python code formatting from python-black, where the readability of code suffers by formatting. Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
Diffstat (limited to 'searx')
-rw-r--r--searx/engines/archlinux.py2
-rw-r--r--searx/engines/bing_news.py4
-rw-r--r--searx/engines/sepiasearch.py2
-rw-r--r--searx/engines/wikidata.py22
-rw-r--r--searx/plugins/__init__.py4
-rw-r--r--searx/preferences.py2
-rw-r--r--searx/search/checker/impl.py2
-rw-r--r--searx/search/processors/online.py2
-rwxr-xr-xsearx/webapp.py12
9 files changed, 44 insertions, 8 deletions
diff --git a/searx/engines/archlinux.py b/searx/engines/archlinux.py
index aeac145d1..1aa8d0ade 100644
--- a/searx/engines/archlinux.py
+++ b/searx/engines/archlinux.py
@@ -39,6 +39,7 @@ def locale_to_lang_code(locale):
# wikis for some languages were moved off from the main site, we need to make
# requests to correct URLs to be able to get results in those languages
lang_urls = {
+ # fmt: off
'all': {
'base': 'https://wiki.archlinux.org',
'search': '/index.php?title=Special:Search&offset={offset}&{query}'
@@ -63,6 +64,7 @@ lang_urls = {
'base': 'http://archtr.org/wiki',
'search': '/index.php?title=Özel:Ara&offset={offset}&{query}'
}
+ # fmt: on
}
diff --git a/searx/engines/bing_news.py b/searx/engines/bing_news.py
index c2515385c..f0bc8bead 100644
--- a/searx/engines/bing_news.py
+++ b/searx/engines/bing_news.py
@@ -69,21 +69,25 @@ def image_url_cleanup(url_string):
def _get_url(query, language, offset, time_range):
if time_range in time_range_dict:
search_path = search_string_with_time.format(
+ # fmt: off
query = urlencode({
'q': query,
'setmkt': language
}),
offset = offset,
interval = time_range_dict[time_range]
+ # fmt: on
)
else:
# e.g. setmkt=de-de&setlang=de
search_path = search_string.format(
+ # fmt: off
query = urlencode({
'q': query,
'setmkt': language
}),
offset = offset
+ # fmt: on
)
return base_url + search_path
diff --git a/searx/engines/sepiasearch.py b/searx/engines/sepiasearch.py
index 8ccde404f..ebad20d01 100644
--- a/searx/engines/sepiasearch.py
+++ b/searx/engines/sepiasearch.py
@@ -23,9 +23,11 @@ paging = True
time_range_support = True
safesearch = True
supported_languages = [
+ # fmt: off
'en', 'fr', 'ja', 'eu', 'ca', 'cs', 'eo', 'el',
'de', 'it', 'nl', 'es', 'oc', 'gd', 'zh', 'pt',
'sv', 'pl', 'fi', 'ru'
+ # fmt: on
]
base_url = 'https://sepiasearch.org/api/v1/search/videos'
diff --git a/searx/engines/wikidata.py b/searx/engines/wikidata.py
index f0dfc7595..59413499c 100644
--- a/searx/engines/wikidata.py
+++ b/searx/engines/wikidata.py
@@ -92,14 +92,20 @@ WHERE {
# https://www.w3.org/TR/sparql11-query/#rSTRING_LITERAL1
# https://lists.w3.org/Archives/Public/public-rdf-dawg/2011OctDec/0175.html
-sparql_string_escape = get_string_replaces_function({'\t': '\\\t',
- '\n': '\\\n',
- '\r': '\\\r',
- '\b': '\\\b',
- '\f': '\\\f',
- '\"': '\\\"',
- '\'': '\\\'',
- '\\': '\\\\'})
+sparql_string_escape = get_string_replaces_function(
+ # fmt: off
+ {
+ '\t': '\\\t',
+ '\n': '\\\n',
+ '\r': '\\\r',
+ '\b': '\\\b',
+ '\f': '\\\f',
+ '\"': '\\\"',
+ '\'': '\\\'',
+ '\\': '\\\\'
+ }
+ # fmt: on
+)
replace_http_by_https = get_string_replaces_function({'http:': 'https:'})
diff --git a/searx/plugins/__init__.py b/searx/plugins/__init__.py
index 91636fe33..4c824da28 100644
--- a/searx/plugins/__init__.py
+++ b/searx/plugins/__init__.py
@@ -17,15 +17,19 @@ from searx import logger, settings
logger = logger.getChild("plugins")
required_attrs = (
+ # fmt: off
("name", str),
("description", str),
("default_on", bool)
+ # fmt: on
)
optional_attrs = (
+ # fmt: off
("js_dependencies", tuple),
("css_dependencies", tuple),
("preference_section", str),
+ # fmt: on
)
diff --git a/searx/preferences.py b/searx/preferences.py
index 4d0cc5c0a..49f6ef202 100644
--- a/searx/preferences.py
+++ b/searx/preferences.py
@@ -325,6 +325,7 @@ class Preferences:
super().__init__()
self.key_value_settings = {
+ # fmt: off
'categories': MultipleChoiceSetting(
['general'],
is_locked('categories'),
@@ -422,6 +423,7 @@ class Preferences:
'False': False
}
),
+ # fmt: on
}
self.engines = EnginesSetting('engines', choices=engines)
diff --git a/searx/search/checker/impl.py b/searx/search/checker/impl.py
index 626aa8ce0..e68248c0e 100644
--- a/searx/search/checker/impl.py
+++ b/searx/search/checker/impl.py
@@ -25,6 +25,7 @@ from searx.metrics import counter_inc
logger = logger.getChild('searx.search.checker')
HTML_TAGS = [
+ # fmt: off
'embed', 'iframe', 'object', 'param', 'picture', 'source', 'svg', 'math', 'canvas', 'noscript', 'script',
'del', 'ins', 'area', 'audio', 'img', 'map', 'track', 'video', 'a', 'abbr', 'b', 'bdi', 'bdo', 'br', 'cite',
'code', 'data', 'dfn', 'em', 'i', 'kdb', 'mark', 'q', 'rb', 'rp', 'rt', 'rtc', 'ruby', 's', 'samp', 'small',
@@ -32,6 +33,7 @@ HTML_TAGS = [
'figcaption', 'figure', 'hr', 'li', 'ol', 'p', 'pre', 'ul', 'button', 'datalist', 'fieldset', 'form', 'input',
'label', 'legend', 'meter', 'optgroup', 'option', 'output', 'progress', 'select', 'textarea', 'applet',
'frame', 'frameset'
+ # fmt: on
]
diff --git a/searx/search/processors/online.py b/searx/search/processors/online.py
index c4ee58e11..674ba9c8e 100644
--- a/searx/search/processors/online.py
+++ b/searx/search/processors/online.py
@@ -23,6 +23,7 @@ from .abstract import EngineProcessor
def default_request_params():
"""Default request parameters for ``online`` engines."""
return {
+ # fmt: off
'method': 'GET',
'headers': {},
'data': {},
@@ -30,6 +31,7 @@ def default_request_params():
'cookies': {},
'verify': True,
'auth': None
+ # fmt: on
}
diff --git a/searx/webapp.py b/searx/webapp.py
index b6dc18937..7729eb538 100755
--- a/searx/webapp.py
+++ b/searx/webapp.py
@@ -616,8 +616,10 @@ def index_error(output_format, error_message):
# html
request.errors.append(gettext('search error'))
return render(
+ # fmt: off
'index.html',
selected_categories=get_selected_categories(request.preferences, request.form),
+ # fmt: on
)
@@ -631,8 +633,10 @@ def index():
return redirect(url_for('search') + query, 308)
return render(
+ # fmt: off
'index.html',
selected_categories=get_selected_categories(request.preferences, request.form),
+ # fmt: on
)
@@ -662,8 +666,10 @@ def search():
if not request.form.get('q'):
if output_format == 'html':
return render(
+ # fmt: off
'index.html',
selected_categories=get_selected_categories(request.preferences, request.form),
+ # fmt: on
)
return index_error(output_format, 'No query'), 400
@@ -811,6 +817,7 @@ def search():
))
return render(
+ # fmt: off
'results.html',
results = results,
q=request.form['q'],
@@ -835,6 +842,7 @@ def search():
theme = get_current_theme_name(),
favicons = global_favicons[themes.index(get_current_theme_name())],
timeout_limit = request.form.get('timeout_limit', None)
+ # fmt: on
)
@@ -1045,6 +1053,7 @@ def preferences():
}
return render(
+ # fmt: off
'preferences.html',
selected_categories = get_selected_categories(request.preferences, request.form),
locales = LOCALE_NAMES,
@@ -1071,6 +1080,7 @@ def preferences():
preferences_url_params = request.preferences.get_as_url_params(),
locked_preferences = settings['preferences']['lock'],
preferences = True
+ # fmt: on
)
@@ -1233,12 +1243,14 @@ def stats():
engine_stats['time'] = sorted(engine_stats['time'], reverse=reverse, key=get_key)
return render(
+ # fmt: off
'stats.html',
sort_order = sort_order,
engine_stats = engine_stats,
engine_reliabilities = engine_reliabilities,
selected_engine_name = selected_engine_name,
searx_git_branch = GIT_BRANCH,
+ # fmt: on
)