euscan: plugin system for handlers
Signed-off-by: volpino <fox91@anche.no>
This commit is contained in:
@ -1,6 +1,17 @@
|
||||
from euscan.handlers import generic, php, pypi, rubygem, kde, cpan, github
|
||||
import pkgutil
|
||||
|
||||
handlers = [kde, php, pypi, rubygem, cpan, github, generic]
|
||||
# autoimport all modules in this directory and append them to handlers list
|
||||
handlers = []
|
||||
for loader, module_name, is_pkg in pkgutil.walk_packages(__path__):
|
||||
module = loader.find_module(module_name).load_module(module_name)
|
||||
handlers.append(module)
|
||||
|
||||
# sort handlers by priority (e.g.: generic should be run lastly)
|
||||
handlers = sorted(
|
||||
handlers,
|
||||
key=lambda handler: handler.PRIORITY,
|
||||
reverse=True
|
||||
)
|
||||
|
||||
|
||||
def find_best_handler(cpv, url):
|
||||
|
Reference in New Issue
Block a user