euscan: Adding support for disabling handlers
Signed-off-by: volpino <fox91@anche.no>
This commit is contained in:
@ -7,6 +7,7 @@ __version__ = "git"
|
||||
|
||||
import ConfigParser
|
||||
import os
|
||||
from ast import literal_eval
|
||||
|
||||
|
||||
CONFIG = {
|
||||
@ -29,6 +30,7 @@ CONFIG = {
|
||||
'ignore-pre-release': False,
|
||||
'ignore-pre-release-if-stable': False,
|
||||
'ebuild-uri': False,
|
||||
'handlers-exclude': [],
|
||||
}
|
||||
|
||||
config = ConfigParser.ConfigParser()
|
||||
@ -36,7 +38,7 @@ config.read(['/etc/euscan.conf', os.path.expanduser('~/.euscan.conf')])
|
||||
if config.has_section("euscan"):
|
||||
for key, value in config.items("euscan"):
|
||||
if key in CONFIG:
|
||||
CONFIG[key] = value
|
||||
CONFIG[key] = literal_eval(value)
|
||||
|
||||
BLACKLIST_VERSIONS = [
|
||||
# Compatibility package for running binaries linked against a
|
||||
|
@ -37,7 +37,8 @@ def find_best_handler(kind, pkg, *args):
|
||||
Find the best handler for the given package
|
||||
"""
|
||||
for handler in handlers[kind]:
|
||||
if handler.can_handle(pkg, *args):
|
||||
if (handler.HANDLER_NAME not in CONFIG["handlers-exclude"] and
|
||||
handler.can_handle(pkg, *args)):
|
||||
return handler
|
||||
return None
|
||||
|
||||
@ -149,8 +150,11 @@ def scan_url(pkg, urls, options, on_progress=None):
|
||||
|
||||
try:
|
||||
url_handler = find_best_handler('url', pkg, url)
|
||||
for o in options:
|
||||
versions += url_handler.scan_url(pkg, url, o)
|
||||
if url_handler:
|
||||
for o in options:
|
||||
versions += url_handler.scan_url(pkg, url, o)
|
||||
else:
|
||||
output.eerror("Can't find a suitable handler!")
|
||||
except Exception as e:
|
||||
output.ewarn(
|
||||
"Handler failed: [%s] %s" %
|
||||
|
Reference in New Issue
Block a user