euscan: plugin system for handlers

Signed-off-by: volpino <fox91@anche.no>
This commit is contained in:
volpino
2012-06-28 11:08:05 +02:00
parent 951624759a
commit b06965f386
8 changed files with 27 additions and 3 deletions

View File

@ -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):