mirror of
https://git.launchpad.net/~ubuntu-release/britney/+git/britney2-ubuntu
synced 2025-02-10 14:07:29 +00:00
Fixed the tab-completer in hint-tester
It was temporarily broken by commit 5814723. Signed-off-by: Niels Thykier <niels@thykier.net>
This commit is contained in:
parent
5814723a08
commit
8a1a43c965
23
completer.py
23
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:
|
||||
|
Loading…
x
Reference in New Issue
Block a user