Make the tab-completer suite agnostic

Signed-off-by: Niels Thykier <niels@thykier.net>
ubuntu/rebased
Niels Thykier 7 years ago
parent 208c3c2e90
commit 74c728bf91

@ -35,28 +35,29 @@ class Completer(object):
'block', 'block-udeb', 'unblock', 'unblock-udeb', 'block', 'block-udeb', 'unblock', 'unblock-udeb',
'approve', 'exit', 'quit'] 'approve', 'exit', 'quit']
self.britney = britney self.britney = britney
suite_info = britney.suite_info
# generate a completion list from excuses. # generate a completion list from excuses.
# - it might contain too many items, but meh # - it might contain too many items, but meh
complete = [] complete = []
tpu = [] tpu = []
for e in britney.excuses.values(): for e in britney.excuses.values():
pkg = e.name pkg = e.name
suite = 'unstable' suite = suite_info.primary_source_suite.name
if pkg[0] == '-': if pkg[0] == '-':
suite = 'testing' suite = suite_info.target_suite.name
pkg = pkg[1:] pkg = pkg[1:]
if "_" in pkg: if "_" in pkg:
(pkg, suite) = pkg.split("_") (pkg, suite) = pkg.split("_")
if "/" in pkg: if "/" in pkg:
pkg = pkg.split("/")[0] pkg = pkg.split("/")[0]
name = "%s/%s" % (e.name, britney.sources[suite][pkg].version) name = "%s/%s" % (e.name, suite_info[suite].sources[pkg].version)
complete.append(name) complete.append(name)
if suite == 'tpu': if suite_info[suite].suite_class.is_additional_source:
tpu.append(name) tpu.append(name)
self.packages = sorted(complete) self.packages = sorted(complete)
self.tpu_packages = sorted(tpu) self.tpu_packages = sorted(tpu)
testing = britney.sources['testing'] target_suite = suite_info.target_suite.sources
self.testing_packages = sorted("%s/%s" % (pkg, testing[pkg].version) for pkg in testing) self.testing_packages = sorted("%s/%s" % (pkg, target_suite[pkg].version) for pkg in target_suite)
def completer(self, text, state): def completer(self, text, state):
"""readline completer (see the readline API)""" """readline completer (see the readline API)"""

Loading…
Cancel
Save