forked from zaclys/searxng
[fix] pep8
This commit is contained in:
parent
ab471fd13b
commit
c051e6a2c3
|
@ -6,12 +6,14 @@ from searx.engines.xpath import extract_text
|
||||||
from searx.languages import language_codes
|
from searx.languages import language_codes
|
||||||
|
|
||||||
categories = ['general']
|
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}'
|
web_url = 'http://mymemory.translated.net/en/{from_lang}/{to_lang}/{query}'
|
||||||
weight = 100
|
weight = 100
|
||||||
|
|
||||||
parser_re = re.compile(u'.*?([a-z]+)-([a-z]+) (.{2,})$', re.I)
|
parser_re = re.compile(u'.*?([a-z]+)-([a-z]+) (.{2,})$', re.I)
|
||||||
|
|
||||||
|
|
||||||
def is_valid_lang(lang):
|
def is_valid_lang(lang):
|
||||||
is_abbr = (len(lang) == 2)
|
is_abbr = (len(lang) == 2)
|
||||||
if is_abbr:
|
if is_abbr:
|
||||||
|
@ -52,12 +54,14 @@ def request(query, params):
|
||||||
def response(resp):
|
def response(resp):
|
||||||
results = []
|
results = []
|
||||||
results.append({
|
results.append({
|
||||||
'url': escape(web_url.format(from_lang=resp.search_params['from_lang'][2],
|
'url': escape(web_url.format(
|
||||||
to_lang=resp.search_params['to_lang'][2],
|
from_lang=resp.search_params['from_lang'][2],
|
||||||
query=resp.search_params['query'])),
|
to_lang=resp.search_params['to_lang'][2],
|
||||||
'title': escape('[{0}-{1}] {2}'.format(resp.search_params['from_lang'][1],
|
query=resp.search_params['query'])),
|
||||||
resp.search_params['to_lang'][1],
|
'title': escape('[{0}-{1}] {2}'.format(
|
||||||
resp.search_params['query'])),
|
resp.search_params['from_lang'][1],
|
||||||
|
resp.search_params['to_lang'][1],
|
||||||
|
resp.search_params['query'])),
|
||||||
'content': escape(resp.json()['responseData']['translatedText'])
|
'content': escape(resp.json()['responseData']['translatedText'])
|
||||||
})
|
})
|
||||||
return results
|
return results
|
||||||
|
|
Loading…
Reference in New Issue