summaryrefslogtreecommitdiff
path: root/searx/engines
diff options
context:
space:
mode:
authorAdam Tauber <asciimoo@gmail.com>2016-11-19 17:51:19 +0100
committerAdam Tauber <asciimoo@gmail.com>2016-11-19 17:51:19 +0100
commit55dc538398090e437c5e495dddad983a7870d09b (patch)
tree6372edb5450684b3e1a575e20c74a61127394746 /searx/engines
parent827f9e41ca84638d873997001b53e7f4a62a78aa (diff)
downloadsearxng-55dc538398090e437c5e495dddad983a7870d09b.tar.gz
searxng-55dc538398090e437c5e495dddad983a7870d09b.zip
[mod] move load_module function to utils
Diffstat (limited to 'searx/engines')
-rw-r--r--searx/engines/__init__.py17
1 files changed, 4 insertions, 13 deletions
diff --git a/searx/engines/__init__.py b/searx/engines/__init__.py
index 14376c31f..116eadc97 100644
--- a/searx/engines/__init__.py
+++ b/searx/engines/__init__.py
@@ -16,13 +16,13 @@ along with searx. If not, see < http://www.gnu.org/licenses/ >.
(C) 2013- by Adam Tauber, <asciimoo@gmail.com>
'''
-from os.path import realpath, dirname, splitext, join
+from os.path import realpath, dirname
import sys
-from imp import load_source
from flask_babel import gettext
from operator import itemgetter
from searx import settings
from searx import logger
+from searx.utils import load_module
logger = logger.getChild('engines')
@@ -32,6 +32,7 @@ engine_dir = dirname(realpath(__file__))
engines = {}
categories = {'general': []}
+_initialized = False
engine_shortcuts = {}
engine_default_args = {'paging': False,
@@ -46,16 +47,6 @@ engine_default_args = {'paging': False,
'time_range_support': False}
-def load_module(filename):
- modname = splitext(filename)[0]
- if modname in sys.modules:
- del sys.modules[modname]
- filepath = join(engine_dir, filename)
- module = load_source(modname, filepath)
- module.name = modname
- return module
-
-
def load_engine(engine_data):
if '_' in engine_data['name']:
@@ -65,7 +56,7 @@ def load_engine(engine_data):
engine_module = engine_data['engine']
try:
- engine = load_module(engine_module + '.py')
+ engine = load_module(engine_module + '.py', engine_dir)
except:
logger.exception('Cannot load engine "{}"'.format(engine_module))
return None