diff options
author | Markus Heiser <markus.heiser@darmarit.de> | 2021-12-27 09:26:22 +0100 |
---|---|---|
committer | Markus Heiser <markus.heiser@darmarit.de> | 2021-12-27 09:26:22 +0100 |
commit | 3d96a9839a12649874b6d4cf9466bd3616b0a03c (patch) | |
tree | e7d54d1e345b1e792d538ddc250f4827bb2fd9b9 /searx/engines/mediawiki.py | |
parent | fcdc2c2cd26e24c2aa3f064d93cee3e29dc2a30c (diff) | |
download | searxng-3d96a9839a12649874b6d4cf9466bd3616b0a03c.tar.gz searxng-3d96a9839a12649874b6d4cf9466bd3616b0a03c.zip |
[format.python] initial formatting of the python code
This patch was generated by black [1]::
make format.python
[1] https://github.com/psf/black
Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
Diffstat (limited to 'searx/engines/mediawiki.py')
-rw-r--r-- | searx/engines/mediawiki.py | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/searx/engines/mediawiki.py b/searx/engines/mediawiki.py index da4321250..9002e9ba7 100644 --- a/searx/engines/mediawiki.py +++ b/searx/engines/mediawiki.py @@ -25,23 +25,24 @@ search_type = 'nearmatch' # possible values: title, text, nearmatch # search-url base_url = 'https://{language}.wikipedia.org/' -search_postfix = 'w/api.php?action=query'\ - '&list=search'\ - '&{query}'\ - '&format=json'\ - '&sroffset={offset}'\ - '&srlimit={limit}'\ +search_postfix = ( + 'w/api.php?action=query' + '&list=search' + '&{query}' + '&format=json' + '&sroffset={offset}' + '&srlimit={limit}' '&srwhat={searchtype}' +) # do search-request def request(query, params): offset = (params['pageno'] - 1) * number_of_results - string_args = dict(query=urlencode({'srsearch': query}), - offset=offset, - limit=number_of_results, - searchtype=search_type) + string_args = dict( + query=urlencode({'srsearch': query}), offset=offset, limit=number_of_results, searchtype=search_type + ) format_strings = list(Formatter().parse(base_url)) @@ -78,13 +79,14 @@ def response(resp): for result in search_results['query']['search']: if result.get('snippet', '').startswith('#REDIRECT'): continue - url = base_url.format(language=resp.search_params['language']) +\ - 'wiki/' + quote(result['title'].replace(' ', '_').encode()) + url = ( + base_url.format(language=resp.search_params['language']) + + 'wiki/' + + quote(result['title'].replace(' ', '_').encode()) + ) # append result - results.append({'url': url, - 'title': result['title'], - 'content': ''}) + results.append({'url': url, 'title': result['title'], 'content': ''}) # return results return results |