mirror of https://github.com/searxng/searxng.git
[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
|
||||
# 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
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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'
|
||||
|
||||
|
|
|
@ -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',
|
||||
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:'})
|
||||
|
||||
|
|
|
@ -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
|
||||
)
|
||||
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
]
|
||||
|
||||
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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
|
||||
)
|
||||
|
||||
|
||||
|
|
|
@ -55,7 +55,9 @@ NOT_A_DESCRIPTION = [
|
|||
]
|
||||
|
||||
SKIP_ENGINE_SOURCE = [
|
||||
# fmt: off
|
||||
('gitlab', 'wikidata') # descriptions are about wikipedia disambiguation pages
|
||||
# fmt: on
|
||||
]
|
||||
|
||||
LANGUAGES = LOCALE_NAMES.keys()
|
||||
|
|
|
@ -19,10 +19,12 @@ NORMAL_REGEX = re.compile('^[0-9]+\.[0-9](\.[0-9])?$')
|
|||
|
||||
#
|
||||
useragents = {
|
||||
# fmt: off
|
||||
"versions": (),
|
||||
"os": ('Windows NT 10.0; Win64; x64',
|
||||
'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,6 +26,7 @@ class LogicodevStyle(Style): # pylint: disable=R0903
|
|||
background_color = '#282C34'
|
||||
|
||||
styles = {
|
||||
# fmt: off
|
||||
Comment: "#556366 italic",
|
||||
Comment.Multiline: "#556366 italic",
|
||||
Comment.Preproc: "#BC7A00",
|
||||
|
@ -51,13 +52,13 @@ class LogicodevStyle(Style): # pylint: disable=R0903
|
|||
Keyword.Type: "#D46C72",
|
||||
Literal.Number: "#D19A66",
|
||||
Literal.String: "#86C372",
|
||||
Literal.String.Backtick:"#86C372",
|
||||
Literal.String.Backtick: "#86C372",
|
||||
Literal.String.Char: "#86C372",
|
||||
Literal.String.Doc: "#86C372 italic",
|
||||
Literal.String.Double: "#86C372",
|
||||
Literal.String.Escape: "#BB6622 bold",
|
||||
Literal.String.Heredoc: "#86C372",
|
||||
Literal.String.Interpol:"#BB6688 bold",
|
||||
Literal.String.Interpol: "#BB6688 bold",
|
||||
Literal.String.Other: "#BE74D5",
|
||||
Literal.String.Regex: "#BB6688",
|
||||
Literal.String.Single: "#86C372",
|
||||
|
@ -81,6 +82,7 @@ class LogicodevStyle(Style): # pylint: disable=R0903
|
|||
Operator: "#D19A66",
|
||||
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',
|
||||
content='bbb',
|
||||
engine='wikipedia', **kwargs):
|
||||
result = {'url': url,
|
||||
result = {
|
||||
# fmt: off
|
||||
'url': url,
|
||||
'title': title,
|
||||
'content': content,
|
||||
'engine': engine}
|
||||
'engine': engine,
|
||||
# fmt: on
|
||||
}
|
||||
result.update(kwargs)
|
||||
return result
|
||||
|
||||
|
|
Loading…
Reference in New Issue