forked from Icycoide/searxng
[enh] py3 compatibility
This commit is contained in:
parent
46a2c63f8e
commit
52e615dede
115 changed files with 517 additions and 513 deletions
|
@ -1,8 +1,12 @@
|
|||
from os import listdir
|
||||
from os.path import realpath, dirname, join, isdir
|
||||
from sys import version_info
|
||||
from searx.utils import load_module
|
||||
from collections import defaultdict
|
||||
|
||||
if version_info[0] == 3:
|
||||
unicode = str
|
||||
|
||||
|
||||
answerers_dir = dirname(realpath(__file__))
|
||||
|
||||
|
@ -10,7 +14,7 @@ answerers_dir = dirname(realpath(__file__))
|
|||
def load_answerers():
|
||||
answerers = []
|
||||
for filename in listdir(answerers_dir):
|
||||
if not isdir(join(answerers_dir, filename)):
|
||||
if not isdir(join(answerers_dir, filename)) or filename.startswith('_'):
|
||||
continue
|
||||
module = load_module('answerer.py', join(answerers_dir, filename))
|
||||
if not hasattr(module, 'keywords') or not isinstance(module.keywords, tuple) or not len(module.keywords):
|
||||
|
@ -30,12 +34,12 @@ def get_answerers_by_keywords(answerers):
|
|||
|
||||
def ask(query):
|
||||
results = []
|
||||
query_parts = filter(None, query.query.split())
|
||||
query_parts = list(filter(None, query.query.split()))
|
||||
|
||||
if query_parts[0] not in answerers_by_keywords:
|
||||
if query_parts[0].decode('utf-8') not in answerers_by_keywords:
|
||||
return results
|
||||
|
||||
for answerer in answerers_by_keywords[query_parts[0]]:
|
||||
for answerer in answerers_by_keywords[query_parts[0].decode('utf-8')]:
|
||||
result = answerer(query)
|
||||
if result:
|
||||
results.append(result)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue