mirror of
https://git.launchpad.net/~ubuntu-release/britney/+git/britney2-ubuntu
synced 2025-05-13 19:41: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
c4a8b31edf
commit
5ef956489a
23
completer.py
23
completer.py
@ -30,8 +30,21 @@ class Completer:
|
|||||||
self.matches = []
|
self.matches = []
|
||||||
self.cmds = ['easy', 'hint', 'force-hint', 'exit', 'quit']
|
self.cmds = ['easy', 'hint', 'force-hint', 'exit', 'quit']
|
||||||
self.britney = britney
|
self.britney = britney
|
||||||
# copy upgrade_me
|
# generate a completion list from excuses.
|
||||||
self.packages = britney.upgrade_me[:]
|
# - 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):
|
def completer(self, text, state):
|
||||||
"""readline completer (see the readline API)"""
|
"""readline completer (see the readline API)"""
|
||||||
@ -46,15 +59,11 @@ class Completer:
|
|||||||
self.matches = [x for x in self.cmds if x.startswith(text)]
|
self.matches = [x for x in self.cmds if x.startswith(text)]
|
||||||
else:
|
else:
|
||||||
# complete pkg/[arch/]version
|
# complete pkg/[arch/]version
|
||||||
prefix = ''
|
|
||||||
if len(text) > 0 and text[0] == '-':
|
|
||||||
text = text[1:]
|
|
||||||
prefix = '-'
|
|
||||||
start = bisect.bisect_left(self.packages, text)
|
start = bisect.bisect_left(self.packages, text)
|
||||||
while start < len(self.packages):
|
while start < len(self.packages):
|
||||||
if not self.packages[start].startswith(text):
|
if not self.packages[start].startswith(text):
|
||||||
break
|
break
|
||||||
self.matches.append(prefix + self.packages[start])
|
self.matches.append(self.packages[start])
|
||||||
start += 1
|
start += 1
|
||||||
|
|
||||||
if len(self.matches) > state:
|
if len(self.matches) > state:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user