forked from zaclys/searxng
[mod] engine load refactor
This commit is contained in:
parent
f13a6ab795
commit
2cfa760b57
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user