From c051e6a2c3e97419983d552594a6a8340339c1d5 Mon Sep 17 00:00:00 2001 From: potato Date: Tue, 6 Sep 2016 15:44:05 +0200 Subject: [PATCH] [fix] pep8 --- searx/engines/translated.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/searx/engines/translated.py b/searx/engines/translated.py index 9f194b76b..2f535140c 100644 --- a/searx/engines/translated.py +++ b/searx/engines/translated.py @@ -6,12 +6,14 @@ from searx.engines.xpath import extract_text from searx.languages import language_codes categories = ['general'] -url = 'http://api.mymemory.translated.net/get?q={query}&langpair={from_lang}|{to_lang}' +url = 'http://api.mymemory.translated.net/get?q={query}' \ + '&langpair={from_lang}|{to_lang}' web_url = 'http://mymemory.translated.net/en/{from_lang}/{to_lang}/{query}' weight = 100 parser_re = re.compile(u'.*?([a-z]+)-([a-z]+) (.{2,})$', re.I) + def is_valid_lang(lang): is_abbr = (len(lang) == 2) if is_abbr: @@ -52,12 +54,14 @@ def request(query, params): def response(resp): results = [] results.append({ - 'url': escape(web_url.format(from_lang=resp.search_params['from_lang'][2], - to_lang=resp.search_params['to_lang'][2], - query=resp.search_params['query'])), - 'title': escape('[{0}-{1}] {2}'.format(resp.search_params['from_lang'][1], - resp.search_params['to_lang'][1], - resp.search_params['query'])), + 'url': escape(web_url.format( + from_lang=resp.search_params['from_lang'][2], + to_lang=resp.search_params['to_lang'][2], + query=resp.search_params['query'])), + 'title': escape('[{0}-{1}] {2}'.format( + resp.search_params['from_lang'][1], + resp.search_params['to_lang'][1], + resp.search_params['query'])), 'content': escape(resp.json()['responseData']['translatedText']) }) return results