forked from zaclys/searxng
[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>
This commit is contained in:
parent
c849731eb1
commit
fcdc2c2cd2
|
@ -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
|
# 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
|
# requests to correct URLs to be able to get results in those languages
|
||||||
lang_urls = {
|
lang_urls = {
|
||||||
|
# fmt: off
|
||||||
'all': {
|
'all': {
|
||||||
'base': 'https://wiki.archlinux.org',
|
'base': 'https://wiki.archlinux.org',
|
||||||
'search': '/index.php?title=Special:Search&offset={offset}&{query}'
|
'search': '/index.php?title=Special:Search&offset={offset}&{query}'
|
||||||
|
@ -63,6 +64,7 @@ lang_urls = {
|
||||||
'base': 'http://archtr.org/wiki',
|
'base': 'http://archtr.org/wiki',
|
||||||
'search': '/index.php?title=Özel:Ara&offset={offset}&{query}'
|
'search': '/index.php?title=Özel:Ara&offset={offset}&{query}'
|
||||||
}
|
}
|
||||||
|
# fmt: on
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -69,21 +69,25 @@ def image_url_cleanup(url_string):
|
||||||
def _get_url(query, language, offset, time_range):
|
def _get_url(query, language, offset, time_range):
|
||||||
if time_range in time_range_dict:
|
if time_range in time_range_dict:
|
||||||
search_path = search_string_with_time.format(
|
search_path = search_string_with_time.format(
|
||||||
|
# fmt: off
|
||||||
query = urlencode({
|
query = urlencode({
|
||||||
'q': query,
|
'q': query,
|
||||||
'setmkt': language
|
'setmkt': language
|
||||||
}),
|
}),
|
||||||
offset = offset,
|
offset = offset,
|
||||||
interval = time_range_dict[time_range]
|
interval = time_range_dict[time_range]
|
||||||
|
# fmt: on
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
# e.g. setmkt=de-de&setlang=de
|
# e.g. setmkt=de-de&setlang=de
|
||||||
search_path = search_string.format(
|
search_path = search_string.format(
|
||||||
|
# fmt: off
|
||||||
query = urlencode({
|
query = urlencode({
|
||||||
'q': query,
|
'q': query,
|
||||||
'setmkt': language
|
'setmkt': language
|
||||||
}),
|
}),
|
||||||
offset = offset
|
offset = offset
|
||||||
|
# fmt: on
|
||||||
)
|
)
|
||||||
return base_url + search_path
|
return base_url + search_path
|
||||||
|
|
||||||
|
|
|
@ -23,9 +23,11 @@ paging = True
|
||||||
time_range_support = True
|
time_range_support = True
|
||||||
safesearch = True
|
safesearch = True
|
||||||
supported_languages = [
|
supported_languages = [
|
||||||
|
# fmt: off
|
||||||
'en', 'fr', 'ja', 'eu', 'ca', 'cs', 'eo', 'el',
|
'en', 'fr', 'ja', 'eu', 'ca', 'cs', 'eo', 'el',
|
||||||
'de', 'it', 'nl', 'es', 'oc', 'gd', 'zh', 'pt',
|
'de', 'it', 'nl', 'es', 'oc', 'gd', 'zh', 'pt',
|
||||||
'sv', 'pl', 'fi', 'ru'
|
'sv', 'pl', 'fi', 'ru'
|
||||||
|
# fmt: on
|
||||||
]
|
]
|
||||||
base_url = 'https://sepiasearch.org/api/v1/search/videos'
|
base_url = 'https://sepiasearch.org/api/v1/search/videos'
|
||||||
|
|
||||||
|
|
|
@ -92,14 +92,20 @@ WHERE {
|
||||||
|
|
||||||
# https://www.w3.org/TR/sparql11-query/#rSTRING_LITERAL1
|
# https://www.w3.org/TR/sparql11-query/#rSTRING_LITERAL1
|
||||||
# https://lists.w3.org/Archives/Public/public-rdf-dawg/2011OctDec/0175.html
|
# https://lists.w3.org/Archives/Public/public-rdf-dawg/2011OctDec/0175.html
|
||||||
sparql_string_escape = get_string_replaces_function({'\t': '\\\t',
|
sparql_string_escape = get_string_replaces_function(
|
||||||
'\n': '\\\n',
|
# fmt: off
|
||||||
'\r': '\\\r',
|
{
|
||||||
'\b': '\\\b',
|
'\t': '\\\t',
|
||||||
'\f': '\\\f',
|
'\n': '\\\n',
|
||||||
'\"': '\\\"',
|
'\r': '\\\r',
|
||||||
'\'': '\\\'',
|
'\b': '\\\b',
|
||||||
'\\': '\\\\'})
|
'\f': '\\\f',
|
||||||
|
'\"': '\\\"',
|
||||||
|
'\'': '\\\'',
|
||||||
|
'\\': '\\\\'
|
||||||
|
}
|
||||||
|
# fmt: on
|
||||||
|
)
|
||||||
|
|
||||||
replace_http_by_https = get_string_replaces_function({'http:': 'https:'})
|
replace_http_by_https = get_string_replaces_function({'http:': 'https:'})
|
||||||
|
|
||||||
|
|
|
@ -17,15 +17,19 @@ from searx import logger, settings
|
||||||
logger = logger.getChild("plugins")
|
logger = logger.getChild("plugins")
|
||||||
|
|
||||||
required_attrs = (
|
required_attrs = (
|
||||||
|
# fmt: off
|
||||||
("name", str),
|
("name", str),
|
||||||
("description", str),
|
("description", str),
|
||||||
("default_on", bool)
|
("default_on", bool)
|
||||||
|
# fmt: on
|
||||||
)
|
)
|
||||||
|
|
||||||
optional_attrs = (
|
optional_attrs = (
|
||||||
|
# fmt: off
|
||||||
("js_dependencies", tuple),
|
("js_dependencies", tuple),
|
||||||
("css_dependencies", tuple),
|
("css_dependencies", tuple),
|
||||||
("preference_section", str),
|
("preference_section", str),
|
||||||
|
# fmt: on
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -325,6 +325,7 @@ class Preferences:
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
|
||||||
self.key_value_settings = {
|
self.key_value_settings = {
|
||||||
|
# fmt: off
|
||||||
'categories': MultipleChoiceSetting(
|
'categories': MultipleChoiceSetting(
|
||||||
['general'],
|
['general'],
|
||||||
is_locked('categories'),
|
is_locked('categories'),
|
||||||
|
@ -422,6 +423,7 @@ class Preferences:
|
||||||
'False': False
|
'False': False
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
|
# fmt: on
|
||||||
}
|
}
|
||||||
|
|
||||||
self.engines = EnginesSetting('engines', choices=engines)
|
self.engines = EnginesSetting('engines', choices=engines)
|
||||||
|
|
|
@ -25,6 +25,7 @@ from searx.metrics import counter_inc
|
||||||
logger = logger.getChild('searx.search.checker')
|
logger = logger.getChild('searx.search.checker')
|
||||||
|
|
||||||
HTML_TAGS = [
|
HTML_TAGS = [
|
||||||
|
# fmt: off
|
||||||
'embed', 'iframe', 'object', 'param', 'picture', 'source', 'svg', 'math', 'canvas', 'noscript', 'script',
|
'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',
|
'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',
|
'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',
|
'figcaption', 'figure', 'hr', 'li', 'ol', 'p', 'pre', 'ul', 'button', 'datalist', 'fieldset', 'form', 'input',
|
||||||
'label', 'legend', 'meter', 'optgroup', 'option', 'output', 'progress', 'select', 'textarea', 'applet',
|
'label', 'legend', 'meter', 'optgroup', 'option', 'output', 'progress', 'select', 'textarea', 'applet',
|
||||||
'frame', 'frameset'
|
'frame', 'frameset'
|
||||||
|
# fmt: on
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,7 @@ from .abstract import EngineProcessor
|
||||||
def default_request_params():
|
def default_request_params():
|
||||||
"""Default request parameters for ``online`` engines."""
|
"""Default request parameters for ``online`` engines."""
|
||||||
return {
|
return {
|
||||||
|
# fmt: off
|
||||||
'method': 'GET',
|
'method': 'GET',
|
||||||
'headers': {},
|
'headers': {},
|
||||||
'data': {},
|
'data': {},
|
||||||
|
@ -30,6 +31,7 @@ def default_request_params():
|
||||||
'cookies': {},
|
'cookies': {},
|
||||||
'verify': True,
|
'verify': True,
|
||||||
'auth': None
|
'auth': None
|
||||||
|
# fmt: on
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -616,8 +616,10 @@ def index_error(output_format, error_message):
|
||||||
# html
|
# html
|
||||||
request.errors.append(gettext('search error'))
|
request.errors.append(gettext('search error'))
|
||||||
return render(
|
return render(
|
||||||
|
# fmt: off
|
||||||
'index.html',
|
'index.html',
|
||||||
selected_categories=get_selected_categories(request.preferences, request.form),
|
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 redirect(url_for('search') + query, 308)
|
||||||
|
|
||||||
return render(
|
return render(
|
||||||
|
# fmt: off
|
||||||
'index.html',
|
'index.html',
|
||||||
selected_categories=get_selected_categories(request.preferences, request.form),
|
selected_categories=get_selected_categories(request.preferences, request.form),
|
||||||
|
# fmt: on
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -662,8 +666,10 @@ def search():
|
||||||
if not request.form.get('q'):
|
if not request.form.get('q'):
|
||||||
if output_format == 'html':
|
if output_format == 'html':
|
||||||
return render(
|
return render(
|
||||||
|
# fmt: off
|
||||||
'index.html',
|
'index.html',
|
||||||
selected_categories=get_selected_categories(request.preferences, request.form),
|
selected_categories=get_selected_categories(request.preferences, request.form),
|
||||||
|
# fmt: on
|
||||||
)
|
)
|
||||||
return index_error(output_format, 'No query'), 400
|
return index_error(output_format, 'No query'), 400
|
||||||
|
|
||||||
|
@ -811,6 +817,7 @@ def search():
|
||||||
))
|
))
|
||||||
|
|
||||||
return render(
|
return render(
|
||||||
|
# fmt: off
|
||||||
'results.html',
|
'results.html',
|
||||||
results = results,
|
results = results,
|
||||||
q=request.form['q'],
|
q=request.form['q'],
|
||||||
|
@ -835,6 +842,7 @@ def search():
|
||||||
theme = get_current_theme_name(),
|
theme = get_current_theme_name(),
|
||||||
favicons = global_favicons[themes.index(get_current_theme_name())],
|
favicons = global_favicons[themes.index(get_current_theme_name())],
|
||||||
timeout_limit = request.form.get('timeout_limit', None)
|
timeout_limit = request.form.get('timeout_limit', None)
|
||||||
|
# fmt: on
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -1045,6 +1053,7 @@ def preferences():
|
||||||
}
|
}
|
||||||
|
|
||||||
return render(
|
return render(
|
||||||
|
# fmt: off
|
||||||
'preferences.html',
|
'preferences.html',
|
||||||
selected_categories = get_selected_categories(request.preferences, request.form),
|
selected_categories = get_selected_categories(request.preferences, request.form),
|
||||||
locales = LOCALE_NAMES,
|
locales = LOCALE_NAMES,
|
||||||
|
@ -1071,6 +1080,7 @@ def preferences():
|
||||||
preferences_url_params = request.preferences.get_as_url_params(),
|
preferences_url_params = request.preferences.get_as_url_params(),
|
||||||
locked_preferences = settings['preferences']['lock'],
|
locked_preferences = settings['preferences']['lock'],
|
||||||
preferences = True
|
preferences = True
|
||||||
|
# fmt: on
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -1233,12 +1243,14 @@ def stats():
|
||||||
|
|
||||||
engine_stats['time'] = sorted(engine_stats['time'], reverse=reverse, key=get_key)
|
engine_stats['time'] = sorted(engine_stats['time'], reverse=reverse, key=get_key)
|
||||||
return render(
|
return render(
|
||||||
|
# fmt: off
|
||||||
'stats.html',
|
'stats.html',
|
||||||
sort_order = sort_order,
|
sort_order = sort_order,
|
||||||
engine_stats = engine_stats,
|
engine_stats = engine_stats,
|
||||||
engine_reliabilities = engine_reliabilities,
|
engine_reliabilities = engine_reliabilities,
|
||||||
selected_engine_name = selected_engine_name,
|
selected_engine_name = selected_engine_name,
|
||||||
searx_git_branch = GIT_BRANCH,
|
searx_git_branch = GIT_BRANCH,
|
||||||
|
# fmt: on
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -55,7 +55,9 @@ NOT_A_DESCRIPTION = [
|
||||||
]
|
]
|
||||||
|
|
||||||
SKIP_ENGINE_SOURCE = [
|
SKIP_ENGINE_SOURCE = [
|
||||||
|
# fmt: off
|
||||||
('gitlab', 'wikidata') # descriptions are about wikipedia disambiguation pages
|
('gitlab', 'wikidata') # descriptions are about wikipedia disambiguation pages
|
||||||
|
# fmt: on
|
||||||
]
|
]
|
||||||
|
|
||||||
LANGUAGES = LOCALE_NAMES.keys()
|
LANGUAGES = LOCALE_NAMES.keys()
|
||||||
|
|
|
@ -19,10 +19,12 @@ NORMAL_REGEX = re.compile('^[0-9]+\.[0-9](\.[0-9])?$')
|
||||||
|
|
||||||
#
|
#
|
||||||
useragents = {
|
useragents = {
|
||||||
|
# fmt: off
|
||||||
"versions": (),
|
"versions": (),
|
||||||
"os": ('Windows NT 10.0; Win64; x64',
|
"os": ('Windows NT 10.0; Win64; x64',
|
||||||
'X11; Linux x86_64'),
|
'X11; Linux x86_64'),
|
||||||
"ua": "Mozilla/5.0 ({os}; rv:{version}) Gecko/20100101 Firefox/{version}"
|
"ua": "Mozilla/5.0 ({os}; rv:{version}) Gecko/20100101 Firefox/{version}",
|
||||||
|
# fmt: on
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -26,61 +26,63 @@ class LogicodevStyle(Style): # pylint: disable=R0903
|
||||||
background_color = '#282C34'
|
background_color = '#282C34'
|
||||||
|
|
||||||
styles = {
|
styles = {
|
||||||
Comment: "#556366 italic",
|
# fmt: off
|
||||||
Comment.Multiline: "#556366 italic",
|
Comment: "#556366 italic",
|
||||||
Comment.Preproc: "#BC7A00",
|
Comment.Multiline: "#556366 italic",
|
||||||
Comment.Single: "#556366 italic",
|
Comment.Preproc: "#BC7A00",
|
||||||
Comment.Special: "#556366 italic",
|
Comment.Single: "#556366 italic",
|
||||||
Error: "border:#ff0000",
|
Comment.Special: "#556366 italic",
|
||||||
Generic.Deleted: "#A00000",
|
Error: "border:#ff0000",
|
||||||
Generic.Emph: "italic",
|
Generic.Deleted: "#A00000",
|
||||||
Generic.Error: "#FF0000",
|
Generic.Emph: "italic",
|
||||||
Generic.Heading: "#000080 bold",
|
Generic.Error: "#FF0000",
|
||||||
Generic.Inserted: "#00A000",
|
Generic.Heading: "#000080 bold",
|
||||||
Generic.Output: "#888888",
|
Generic.Inserted: "#00A000",
|
||||||
Generic.Prompt: "#000080 bold",
|
Generic.Output: "#888888",
|
||||||
Generic.Strong: "bold",
|
Generic.Prompt: "#000080 bold",
|
||||||
Generic.Subheading: "#800080 bold",
|
Generic.Strong: "bold",
|
||||||
Generic.Traceback: "#0044DD",
|
Generic.Subheading: "#800080 bold",
|
||||||
Keyword: "#BE74D5 bold",
|
Generic.Traceback: "#0044DD",
|
||||||
Keyword.Constant: "#BE74D5 bold",
|
Keyword: "#BE74D5 bold",
|
||||||
Keyword.Declaration: "#BE74D5 bold",
|
Keyword.Constant: "#BE74D5 bold",
|
||||||
Keyword.Namespace: "#BE74D5 bold",
|
Keyword.Declaration: "#BE74D5 bold",
|
||||||
Keyword.Pseudo: "#BE74D5",
|
Keyword.Namespace: "#BE74D5 bold",
|
||||||
Keyword.Reserved: "#BE74D5 bold",
|
Keyword.Pseudo: "#BE74D5",
|
||||||
Keyword.Type: "#D46C72",
|
Keyword.Reserved: "#BE74D5 bold",
|
||||||
Literal.Number: "#D19A66",
|
Keyword.Type: "#D46C72",
|
||||||
Literal.String: "#86C372",
|
Literal.Number: "#D19A66",
|
||||||
Literal.String.Backtick:"#86C372",
|
Literal.String: "#86C372",
|
||||||
Literal.String.Char: "#86C372",
|
Literal.String.Backtick: "#86C372",
|
||||||
Literal.String.Doc: "#86C372 italic",
|
Literal.String.Char: "#86C372",
|
||||||
Literal.String.Double: "#86C372",
|
Literal.String.Doc: "#86C372 italic",
|
||||||
Literal.String.Escape: "#BB6622 bold",
|
Literal.String.Double: "#86C372",
|
||||||
Literal.String.Heredoc: "#86C372",
|
Literal.String.Escape: "#BB6622 bold",
|
||||||
Literal.String.Interpol:"#BB6688 bold",
|
Literal.String.Heredoc: "#86C372",
|
||||||
Literal.String.Other: "#BE74D5",
|
Literal.String.Interpol: "#BB6688 bold",
|
||||||
Literal.String.Regex: "#BB6688",
|
Literal.String.Other: "#BE74D5",
|
||||||
Literal.String.Single: "#86C372",
|
Literal.String.Regex: "#BB6688",
|
||||||
Literal.String.Symbol: "#DFC06F",
|
Literal.String.Single: "#86C372",
|
||||||
Name.Attribute: "#7D9029",
|
Literal.String.Symbol: "#DFC06F",
|
||||||
Name.Builtin: "#BE74D5",
|
Name.Attribute: "#7D9029",
|
||||||
Name.Builtin.Pseudo: "#BE74D5",
|
Name.Builtin: "#BE74D5",
|
||||||
Name.Class: "#61AFEF bold",
|
Name.Builtin.Pseudo: "#BE74D5",
|
||||||
Name.Constant: "#D19A66",
|
Name.Class: "#61AFEF bold",
|
||||||
Name.Decorator: "#AA22FF",
|
Name.Constant: "#D19A66",
|
||||||
Name.Entity: "#999999 bold",
|
Name.Decorator: "#AA22FF",
|
||||||
Name.Exception: "#D2413A bold",
|
Name.Entity: "#999999 bold",
|
||||||
Name.Function: "#61AFEF",
|
Name.Exception: "#D2413A bold",
|
||||||
Name.Label: "#A0A000",
|
Name.Function: "#61AFEF",
|
||||||
Name.Namespace: "#61AFEF bold",
|
Name.Label: "#A0A000",
|
||||||
Name.Tag: "#BE74D5 bold",
|
Name.Namespace: "#61AFEF bold",
|
||||||
Name.Variable: "#DFC06F",
|
Name.Tag: "#BE74D5 bold",
|
||||||
Name.Variable.Class: "#DFC06F",
|
Name.Variable: "#DFC06F",
|
||||||
Name.Variable.Global: "#DFC06F",
|
Name.Variable.Class: "#DFC06F",
|
||||||
Name.Variable.Instance: "#DFC06F",
|
Name.Variable.Global: "#DFC06F",
|
||||||
Operator: "#D19A66",
|
Name.Variable.Instance: "#DFC06F",
|
||||||
Operator.Word: "#AA22FF bold",
|
Operator: "#D19A66",
|
||||||
Text.Whitespace: "#D7DAE0",
|
Operator.Word: "#AA22FF bold",
|
||||||
|
Text.Whitespace: "#D7DAE0",
|
||||||
|
# fmt: on
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -8,10 +8,14 @@ def fake_result(url='https://aa.bb/cc?dd=ee#ff',
|
||||||
title='aaa',
|
title='aaa',
|
||||||
content='bbb',
|
content='bbb',
|
||||||
engine='wikipedia', **kwargs):
|
engine='wikipedia', **kwargs):
|
||||||
result = {'url': url,
|
result = {
|
||||||
'title': title,
|
# fmt: off
|
||||||
'content': content,
|
'url': url,
|
||||||
'engine': engine}
|
'title': title,
|
||||||
|
'content': content,
|
||||||
|
'engine': engine,
|
||||||
|
# fmt: on
|
||||||
|
}
|
||||||
result.update(kwargs)
|
result.update(kwargs)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue