logo

searx

Unnamed repository; edit this file 'description' to name the repository.
commit: 2cfa760b57748f427e65fbfb6cfff9a6299882b1
parent: f13a6ab795216805960ce73d0bc1530f8e9eb05e
Author: Adam Tauber <asciimoo@gmail.com>
Date:   Sat, 13 Dec 2014 19:26:40 +0100

[mod] engine load refactor

Diffstat:

searx/engines/__init__.py | 16+++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/searx/engines/__init__.py b/searx/engines/__init__.py @@ -41,11 +41,8 @@ def load_module(filename): module.name = modname return module -if 'engines' not in settings or not settings['engines']: - print '[E] Error no engines found. Edit your settings.yml' - exit(2) -for engine_data in settings['engines']: +def load_engine(engine_data): engine_name = engine_data['engine'] engine = load_module(engine_name + '.py') @@ -87,7 +84,6 @@ for engine_data in settings['engines']: print '[E] Engine config error: Missing attribute "{0}.{1}"'.format(engine.name, engine_attr) # noqa sys.exit(1) - engines[engine.name] = engine engine.stats = { 'result_count': 0, 'search_count': 0, @@ -105,6 +101,7 @@ for engine_data in settings['engines']: if engine.shortcut: # TODO check duplications engine_shortcuts[engine.shortcut] = engine.name + return engine def get_engines_stats(): @@ -194,3 +191,12 @@ def get_engines_stats(): sorted(errors, key=itemgetter('avg'), reverse=True) ), ] + + +if 'engines' not in settings or not settings['engines']: + print '[E] Error no engines found. Edit your settings.yml' + exit(2) + +for engine_data in settings['engines']: + engine = load_engine(engine_data) + engines[engine.name] = engine