mirror of
https://github.com/searxng/searxng.git
synced 2025-08-03 02:22:22 +02:00
[enh] is_valid_lang moved to utils
This commit is contained in:
parent
b7d578ae80
commit
983415bc38
3 changed files with 19 additions and 32 deletions
|
@ -13,7 +13,7 @@ from urlparse import urljoin
|
|||
from lxml import html
|
||||
from cgi import escape
|
||||
from searx.engines.xpath import extract_text
|
||||
from searx.languages import language_codes
|
||||
from searx.utils import is_valid_lang
|
||||
|
||||
categories = ['general']
|
||||
url = 'http://api.mymemory.translated.net/get?q={query}' \
|
||||
|
@ -25,20 +25,6 @@ parser_re = re.compile(u'.*?([a-z]+)-([a-z]+) (.{2,})$', re.I)
|
|||
api_key = ''
|
||||
|
||||
|
||||
def is_valid_lang(lang):
|
||||
is_abbr = (len(lang) == 2)
|
||||
if is_abbr:
|
||||
for l in language_codes:
|
||||
if l[0][:2] == lang.lower():
|
||||
return (True, l[0][:2], l[1].lower())
|
||||
return False
|
||||
else:
|
||||
for l in language_codes:
|
||||
if l[1].lower() == lang.lower():
|
||||
return (True, l[0][:2], l[1].lower())
|
||||
return False
|
||||
|
||||
|
||||
def request(query, params):
|
||||
m = parser_re.match(unicode(query, 'utf8'))
|
||||
if not m:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue