From c87ec9a27f2d70c7c6449ed1cadc58d003f6b0c0 Mon Sep 17 00:00:00 2001 From: necoro <> Date: Mon, 7 May 2007 07:30:41 +0000 Subject: added the ability of sorting the pkglist by installation status --- portato/gui/gui_helper.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'portato/gui/gui_helper.py') diff --git a/portato/gui/gui_helper.py b/portato/gui/gui_helper.py index 86fd6ed..df4e1d7 100644 --- a/portato/gui/gui_helper.py +++ b/portato/gui/gui_helper.py @@ -232,16 +232,30 @@ class Database: for key in self._db: # sort alphabetically self._db[key].sort(cmp=cmp, key=lambda x: str.lower(x[0])) - def get_cat (self, cat): + def get_cat (self, cat, byName = True): """Returns the packages in the category. @param cat: category to return the packages from @type cat: string + @param byName: selects whether to return the list sorted by name or by installation + @type byName: boolean @return: list of tuples: (name, is_installed) or [] @rtype: (string, boolean)[]""" try: - return self._db[cat] + if byName: + return self._db[cat] + else: + inst = [] + ninst = [] + for p, i in self._db[cat]: + if i: + inst.append((p,i)) + else: + ninst.append((p,i)) + + return inst+ninst + except KeyError: # cat is in category list - but not in portage debug("Catched KeyError =>", cat, "seems not to be an available category. Have you played with rsync-excludes?") return [] -- cgit v1.2.3-54-g00ecf