From c345dea3b5b9c01a43442a09cb9ac512c6951d49 Mon Sep 17 00:00:00 2001 From: "Adam D. Barratt" Date: Sat, 16 Mar 2013 17:10:11 +0000 Subject: [PATCH] Completer: when processing a "remove", only offer packages from testing Signed-off-by: Adam D. Barratt --- completer.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/completer.py b/completer.py index 851d466..ae927b6 100644 --- a/completer.py +++ b/completer.py @@ -50,7 +50,9 @@ class Completer(object): name = "%s/%s" % (e.name, britney.sources[suite][pkg][0]) # 0 == VERSION complete.append(name) self.packages = sorted(complete) - + testing = britney.sources['testing'] + self.testing_packages = sorted("%s/%s" % (pkg, testing[pkg][0]) for pkg in testing) + def completer(self, text, state): """readline completer (see the readline API)""" @@ -64,11 +66,15 @@ class Completer(object): self.matches = [x for x in self.cmds if x.startswith(text)] else: # complete pkg/[arch/]version - start = bisect.bisect_left(self.packages, text) - while start < len(self.packages): - if not self.packages[start].startswith(text): + if words[0] == 'remove': + packages = self.testing_packages + else: + packages = self.packages + start = bisect.bisect_left(packages, text) + while start < len(packages): + if not packages[start].startswith(text): break - self.matches.append(self.packages[start]) + self.matches.append(packages[start]) start += 1 if len(self.matches) > state: