From 5ef956489a55d97fc9440e0ad86691102596f888 Mon Sep 17 00:00:00 2001 From: Niels Thykier Date: Wed, 4 Jan 2012 17:59:04 +0100 Subject: [PATCH] Fixed the tab-completer in hint-tester It was temporarily broken by commit 5814723. Signed-off-by: Niels Thykier --- completer.py | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/completer.py b/completer.py index bc26045..cbf6117 100644 --- a/completer.py +++ b/completer.py @@ -30,8 +30,21 @@ class Completer: self.matches = [] self.cmds = ['easy', 'hint', 'force-hint', 'exit', 'quit'] self.britney = britney - # copy upgrade_me - self.packages = britney.upgrade_me[:] + # generate a completion list from excuses. + # - it might contain too many items, but meh + complete = [] + for e in britney.excuses: + if e.name[0] == '-': + # do_hint does not work with removals anyway + continue + else: + ver = None + pkg = e.name + if "/" in pkg: + pkg = pkg.split("/")[0] + name = "%s/%s" % (e.name, britney.sources['unstable'][pkg][0]) # 0 == VERSION + complete.append(name) + self.packages = sorted(complete) def completer(self, text, state): """readline completer (see the readline API)""" @@ -46,15 +59,11 @@ class Completer: self.matches = [x for x in self.cmds if x.startswith(text)] else: # complete pkg/[arch/]version - prefix = '' - if len(text) > 0 and text[0] == '-': - text = text[1:] - prefix = '-' start = bisect.bisect_left(self.packages, text) while start < len(self.packages): if not self.packages[start].startswith(text): break - self.matches.append(prefix + self.packages[start]) + self.matches.append(self.packages[start]) start += 1 if len(self.matches) > state: