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 ) diff --git a/searxng_extra/update/update_engine_descriptions.py b/searxng_extra/update/update_engine_descriptions.py index 59a9a72a0..2e16e1029 100755 --- a/searxng_extra/update/update_engine_descriptions.py +++ b/searxng_extra/update/update_engine_descriptions.py @@ -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() diff --git a/searxng_extra/update/update_firefox_version.py b/searxng_extra/update/update_firefox_version.py index 07bcef7f6..3b536f296 100755 --- a/searxng_extra/update/update_firefox_version.py +++ b/searxng_extra/update/update_firefox_version.py @@ -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 } diff --git a/searxng_extra/update/update_pygments.py b/searxng_extra/update/update_pygments.py index 3b1c525a5..fee63faa5 100755 --- a/searxng_extra/update/update_pygments.py +++ b/searxng_extra/update/update_pygments.py @@ -26,61 +26,63 @@ class LogicodevStyle(Style): # pylint: disable=R0903 background_color = '#282C34' styles = { - Comment: "#556366 italic", - Comment.Multiline: "#556366 italic", - Comment.Preproc: "#BC7A00", - Comment.Single: "#556366 italic", - Comment.Special: "#556366 italic", - Error: "border:#ff0000", - Generic.Deleted: "#A00000", - Generic.Emph: "italic", - Generic.Error: "#FF0000", - Generic.Heading: "#000080 bold", - Generic.Inserted: "#00A000", - Generic.Output: "#888888", - Generic.Prompt: "#000080 bold", - Generic.Strong: "bold", - Generic.Subheading: "#800080 bold", - Generic.Traceback: "#0044DD", - Keyword: "#BE74D5 bold", - Keyword.Constant: "#BE74D5 bold", - Keyword.Declaration: "#BE74D5 bold", - Keyword.Namespace: "#BE74D5 bold", - Keyword.Pseudo: "#BE74D5", - Keyword.Reserved: "#BE74D5 bold", - Keyword.Type: "#D46C72", - Literal.Number: "#D19A66", - Literal.String: "#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.Other: "#BE74D5", - Literal.String.Regex: "#BB6688", - Literal.String.Single: "#86C372", - Literal.String.Symbol: "#DFC06F", - Name.Attribute: "#7D9029", - Name.Builtin: "#BE74D5", - Name.Builtin.Pseudo: "#BE74D5", - Name.Class: "#61AFEF bold", - Name.Constant: "#D19A66", - Name.Decorator: "#AA22FF", - Name.Entity: "#999999 bold", - Name.Exception: "#D2413A bold", - Name.Function: "#61AFEF", - Name.Label: "#A0A000", - Name.Namespace: "#61AFEF bold", - Name.Tag: "#BE74D5 bold", - Name.Variable: "#DFC06F", - Name.Variable.Class: "#DFC06F", - Name.Variable.Global: "#DFC06F", - Name.Variable.Instance: "#DFC06F", - Operator: "#D19A66", - Operator.Word: "#AA22FF bold", - Text.Whitespace: "#D7DAE0", + # fmt: off + Comment: "#556366 italic", + Comment.Multiline: "#556366 italic", + Comment.Preproc: "#BC7A00", + Comment.Single: "#556366 italic", + Comment.Special: "#556366 italic", + Error: "border:#ff0000", + Generic.Deleted: "#A00000", + Generic.Emph: "italic", + Generic.Error: "#FF0000", + Generic.Heading: "#000080 bold", + Generic.Inserted: "#00A000", + Generic.Output: "#888888", + Generic.Prompt: "#000080 bold", + Generic.Strong: "bold", + Generic.Subheading: "#800080 bold", + Generic.Traceback: "#0044DD", + Keyword: "#BE74D5 bold", + Keyword.Constant: "#BE74D5 bold", + Keyword.Declaration: "#BE74D5 bold", + Keyword.Namespace: "#BE74D5 bold", + Keyword.Pseudo: "#BE74D5", + Keyword.Reserved: "#BE74D5 bold", + Keyword.Type: "#D46C72", + Literal.Number: "#D19A66", + Literal.String: "#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.Other: "#BE74D5", + Literal.String.Regex: "#BB6688", + Literal.String.Single: "#86C372", + Literal.String.Symbol: "#DFC06F", + Name.Attribute: "#7D9029", + Name.Builtin: "#BE74D5", + Name.Builtin.Pseudo: "#BE74D5", + Name.Class: "#61AFEF bold", + Name.Constant: "#D19A66", + Name.Decorator: "#AA22FF", + Name.Entity: "#999999 bold", + Name.Exception: "#D2413A bold", + Name.Function: "#61AFEF", + Name.Label: "#A0A000", + Name.Namespace: "#61AFEF bold", + Name.Tag: "#BE74D5 bold", + Name.Variable: "#DFC06F", + Name.Variable.Class: "#DFC06F", + Name.Variable.Global: "#DFC06F", + Name.Variable.Instance: "#DFC06F", + Operator: "#D19A66", + Operator.Word: "#AA22FF bold", + Text.Whitespace: "#D7DAE0", + # fmt: on } diff --git a/tests/unit/test_results.py b/tests/unit/test_results.py index 07d170130..aa99e78c7 100644 --- a/tests/unit/test_results.py +++ b/tests/unit/test_results.py @@ -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, - 'title': title, - 'content': content, - 'engine': engine} + result = { + # fmt: off + 'url': url, + 'title': title, + 'content': content, + 'engine': engine, + # fmt: on + } result.update(kwargs) return result