mirror of
https://github.com/searxng/searxng.git
synced 2024-11-19 02:40:11 +01:00
[fix] unicode and pep8 fixes
This commit is contained in:
parent
4d878993bd
commit
9eb31c0186
@ -205,7 +205,7 @@ def search(query, request, selected_engines, pageno=1, lang='all'):
|
|||||||
request_params['started'] = datetime.now()
|
request_params['started'] = datetime.now()
|
||||||
request_params['pageno'] = pageno
|
request_params['pageno'] = pageno
|
||||||
request_params['language'] = lang
|
request_params['language'] = lang
|
||||||
request_params = engine.request(query, request_params)
|
request_params = engine.request(query.encode('utf-8'), request_params)
|
||||||
|
|
||||||
callback = make_callback(
|
callback = make_callback(
|
||||||
selected_engine['name'],
|
selected_engine['name'],
|
||||||
|
@ -18,7 +18,7 @@ class Search(object):
|
|||||||
self.pageno = 1
|
self.pageno = 1
|
||||||
self.lang = 'all'
|
self.lang = 'all'
|
||||||
if request.cookies.get('blocked_engines'):
|
if request.cookies.get('blocked_engines'):
|
||||||
self.blocked_engines = request.cookies['blocked_engines'].split(',')
|
self.blocked_engines = request.cookies['blocked_engines'].split(',') # noqa
|
||||||
else:
|
else:
|
||||||
self.blocked_engines = []
|
self.blocked_engines = []
|
||||||
self.results = []
|
self.results = []
|
||||||
|
@ -120,8 +120,10 @@ def index():
|
|||||||
search.paging = True
|
search.paging = True
|
||||||
if search.request_data.get('format', 'html') == 'html':
|
if search.request_data.get('format', 'html') == 'html':
|
||||||
if 'content' in result:
|
if 'content' in result:
|
||||||
result['content'] = highlight_content(result['content'], search.query)
|
result['content'] = highlight_content(result['content'],
|
||||||
result['title'] = highlight_content(result['title'], search.query)
|
search.query.encode('utf-8')) # noqa
|
||||||
|
result['title'] = highlight_content(result['title'],
|
||||||
|
search.query.encode('utf-8'))
|
||||||
else:
|
else:
|
||||||
if 'content' in result:
|
if 'content' in result:
|
||||||
result['content'] = html_to_text(result['content']).strip()
|
result['content'] = html_to_text(result['content']).strip()
|
||||||
@ -139,7 +141,8 @@ def index():
|
|||||||
result['favicon'] = engine
|
result['favicon'] = engine
|
||||||
|
|
||||||
if search.request_data.get('format') == 'json':
|
if search.request_data.get('format') == 'json':
|
||||||
return Response(json.dumps({'query': search.query, 'results': search.results}),
|
return Response(json.dumps({'query': search.query,
|
||||||
|
'results': search.results}),
|
||||||
mimetype='application/json')
|
mimetype='application/json')
|
||||||
elif search.request_data.get('format') == 'csv':
|
elif search.request_data.get('format') == 'csv':
|
||||||
csv = UnicodeWriter(cStringIO.StringIO())
|
csv = UnicodeWriter(cStringIO.StringIO())
|
||||||
@ -151,8 +154,8 @@ def index():
|
|||||||
csv.writerow([row.get(key, '') for key in keys])
|
csv.writerow([row.get(key, '') for key in keys])
|
||||||
csv.stream.seek(0)
|
csv.stream.seek(0)
|
||||||
response = Response(csv.stream.read(), mimetype='application/csv')
|
response = Response(csv.stream.read(), mimetype='application/csv')
|
||||||
content_disp = 'attachment;Filename=searx_-_{0}.csv'.format(search.query)
|
cont_disp = 'attachment;Filename=searx_-_{0}.csv'.format(search.query)
|
||||||
response.headers.add('Content-Disposition', content_disp)
|
response.headers.add('Content-Disposition', cont_disp)
|
||||||
return response
|
return response
|
||||||
elif search.request_data.get('format') == 'rss':
|
elif search.request_data.get('format') == 'rss':
|
||||||
response_rss = render(
|
response_rss = render(
|
||||||
|
Loading…
Reference in New Issue
Block a user