on master help sign in
[fix] pep8
commit91f9973227e003604e036278e42a4c6394bf5478 authorThomas Pointhuber <thomas.pointhuber@gmx.at> dateTue 16 Dec 2014, 17:10 (12 years ago) parent672f1c6
2 files changed+24−16
searx/engines/mediawiki.py+7−4 searx/engines/yacy.py+17−12
searx/engines/mediawiki.py+7−4
@@ -28,15 +28,17 @@ search_url = base_url + 'w/api.php?action=query'\
2828 '&srprop=timestamp'\
2929 '&format=json'\
3030 '&sroffset={offset}'\
31− '&srlimit={limit}'
31+ '&srlimit={limit}' # noqa
3232
3333
3434# do search-request
3535def request(query, params):
3636 offset = (params['pageno'] - 1) * number_of_results
37+
3738 string_args = dict(query=urlencode({'srsearch': query}),
38− offset=offset,
39− limit=number_of_results)
39+ offset=offset,
40+ limit=number_of_results)
41+
4042 format_strings = list(Formatter().parse(base_url))
4143
4244 if params['language'] == 'all':
@@ -67,7 +69,8 @@ def response(resp):
6769
6870 # parse results
6971 for result in search_results['query']['search']:
70− url = base_url.format(language=resp.search_params['language']) + 'wiki/' + quote(result['title'].replace(' ', '_').encode('utf-8'))
72+ url = base_url.format(language=resp.search_params['language']) +\
73+ 'wiki/' + quote(result['title'].replace(' ', '_').encode('utf-8'))
7174
7275 # append result
7376 results.append({'url': url,
searx/engines/yacy.py+17−12
@@ -24,7 +24,11 @@ number_of_results = 5
2424
2525# search-url
2626base_url = 'http://localhost:8090'
27−search_url = '/yacysearch.json?{query}&startRecord={offset}&maximumRecords={limit}&contentdom={search_type}&resource=global'
27+search_url = '/yacysearch.json?{query}'\
28+ '&startRecord={offset}'\
29+ '&maximumRecords={limit}'\
30+ '&contentdom={search_type}'\
31+ '&resource=global' # noqa
2832
2933# yacy specific type-definitions
3034search_types = {'general': 'text',
@@ -39,10 +43,11 @@ def request(query, params):
3943 offset = (params['pageno'] - 1) * number_of_results
4044 search_type = search_types.get(params['category'], '0')
4145
42− params['url'] = base_url + search_url.format(query=urlencode({'query': query}),
43− offset=offset,
44− limit=number_of_results,
45− search_type=search_type)
46+ params['url'] = base_url +\
47+ search_url.format(query=urlencode({'query': query}),
48+ offset=offset,
49+ limit=number_of_results,
50+ search_type=search_type)
4651
4752 # add language tag if specified
4853 if params['language'] != 'all':
@@ -70,19 +75,19 @@ def response(resp):
7075
7176 # append result
7277 results.append({'url': result['link'],
73− 'title': result['title'],
74− 'content': result['description'],
75− 'publishedDate': publishedDate})
78+ 'title': result['title'],
79+ 'content': result['description'],
80+ 'publishedDate': publishedDate})
7681
7782 elif resp.search_params['category'] == 'images':
7883 # parse image results
7984 for result in search_results:
8085 # append result
8186 results.append({'url': result['url'],
82− 'title': result['title'],
83− 'content': '',
84− 'img_src': result['image'],
85− 'template': 'images.html'})
87+ 'title': result['title'],
88+ 'content': '',
89+ 'img_src': result['image'],
90+ 'template': 'images.html'})
8691
8792 #TODO parse video, audio and file results
8893