diff options
author | Necoro <> | 2008-02-23 00:05:49 +0000 |
---|---|---|
committer | Necoro <> | 2008-02-23 00:05:49 +0000 |
commit | c47a04e95db9fae95b482aa9aa96bb7a9263c303 (patch) | |
tree | 41f003d0c6c985edc9d0b4bf5442ee32115ed2be /portato/gui/gui_helper.py | |
parent | 5ca8207c8704690fd518b3acb3a28063ce412fbd (diff) | |
download | portato-c47a04e95db9fae95b482aa9aa96bb7a9263c303.tar.gz portato-c47a04e95db9fae95b482aa9aa96bb7a9263c303.tar.bz2 portato-c47a04e95db9fae95b482aa9aa96bb7a9263c303.zip |
r781@Devoty: necoro | 2008-02-23 00:35:34 +0100
New search behavior
r782@Devoty: necoro | 2008-02-23 00:58:59 +0100
Added delete button for the search field
r783@Devoty: necoro | 2008-02-23 01:05:37 +0100
removed underscores in tabs
Diffstat (limited to '')
-rw-r--r-- | portato/gui/gui_helper.py | 61 |
1 files changed, 44 insertions, 17 deletions
diff --git a/portato/gui/gui_helper.py b/portato/gui/gui_helper.py index 91a460f..d48dadd 100644 --- a/portato/gui/gui_helper.py +++ b/portato/gui/gui_helper.py @@ -120,7 +120,7 @@ class Config (ConfigParser): ConfigParser.write(self) self.modify_external_configs() -class Database: +class Database (object): """An internal database which holds a simple dictionary cat -> [package_list].""" ALL = _("ALL") @@ -132,6 +132,7 @@ class Database: def __initialize (self): self._db = {self.ALL:[]} self.inst_cats = set([self.ALL]) + self._restrict = None def __sort_key (self, x): return x[1].lower() @@ -177,19 +178,25 @@ class Database: cat = self.ALL try: - if byName: - for pkg in self._db[cat]: - yield pkg - else: - ninst = [] - for pkg in self._db[cat]: - if pkg[2]: + def get_pkgs(): + if byName: + for pkg in self._db[cat]: + yield pkg + else: + ninst = [] + for pkg in self._db[cat]: + if pkg[2]: + yield pkg + else: + ninst.append(pkg) + + for pkg in ninst: yield pkg - else: - ninst.append(pkg) - for pkg in ninst: - yield pkg + if self.restrict: + return (pkg for pkg in get_pkgs() if pkg[1].find(self.restrict) != -1) + else: + return get_pkgs() except KeyError: # cat is in category list - but not in portage info(_("Catched KeyError => %s seems not to be an available category. Have you played with rsync-excludes?"), cat) @@ -203,13 +210,21 @@ class Database: @rtype: string<iterator> """ - if installed: - c = self.inst_cats + if not self.restrict: + if installed: + cats = self.inst_cats + else: + cats = self._db.iterkeys() + else: - c = self._db.iterkeys() + cats = set((pkg[0] for pkg in self.get_cat(self.ALL))) - for cat in c: - yield cat + if installed: + cats = cats.intersection(self.inst_cats) + + cats.add(self.ALL) + + return (cat for cat in cats) def reload (self, cat = None): """Reloads the given category. @@ -229,6 +244,18 @@ class Database: self.__initialize() self.populate() + def get_restrict (self): + return self._restrict + + def set_restrict (self, restrict): + if not restrict: + self._restrict = None + else: + #self._restrict = re.compile(".*%s.*" % restrict) + self._restrict = restrict + + restrict = property(get_restrict, set_restrict) + class EmergeQueue: """This class manages the emerge queue.""" |