diff --git a/TODO b/TODO index 8c7cf35..aad1854 100644 --- a/TODO +++ b/TODO @@ -9,7 +9,6 @@ euscan - Check other distros (youri, distrowatch, distromatch, whoas; Equivalent-Packages) - Steal ideas from other tools (uscan, portscout) - Steal data from other tools (dehs) -- Add a way to enable/disable handlers (--no-handler-kde --no-handler-sourceforge) ### Command line interface diff --git a/bin/euscan b/bin/euscan index 79053e5..255151b 100755 --- a/bin/euscan +++ b/bin/euscan @@ -133,6 +133,9 @@ def print_usage(_error=None, help=None): " - use mirror:// URIs", file=out) print(yellow(" --ebuild-uri") + " - use ebuild variables in URIs", file=out) + print(yellow(" --no-handlers") + + " - exclude handlers (comma-separated list)", + file=out) print(file=out) if _error in ('packages',) or help: @@ -194,6 +197,8 @@ def parse_args(): CONFIG['ignore-pre-release-if-stable'] = True elif o in ("--ebuild-uri"): CONFIG['ebuild-uri'] = True + elif o in ("--no-handlers"): + CONFIG['handlers-exclude'] = a.split(",") else: return_code = False @@ -205,7 +210,7 @@ def parse_args(): getopt_options['long']['global'] = [ "help", "version", "nocolor", "quiet", "verbose", "oneshot", "brute-force=", "format=", "progress", "mirror", "ignore-pre-release", - "ignore-pre-release-if-stable", "ebuild-uri" + "ignore-pre-release-if-stable", "ebuild-uri", "no-handlers=" ] short_opts = getopt_options['short']['global'] diff --git a/pym/euscan/__init__.py b/pym/euscan/__init__.py index 946c63c..49241dd 100644 --- a/pym/euscan/__init__.py +++ b/pym/euscan/__init__.py @@ -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 diff --git a/pym/euscan/handlers/__init__.py b/pym/euscan/handlers/__init__.py index ee4dedf..e89a0fc 100644 --- a/pym/euscan/handlers/__init__.py +++ b/pym/euscan/handlers/__init__.py @@ -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" %