summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--portato/db/database.py4
-rw-r--r--portato/db/dict.py7
-rw-r--r--portato/db/sql.py12
-rw-r--r--portato/gui/windows/main.py10
4 files changed, 21 insertions, 12 deletions
diff --git a/portato/db/database.py b/portato/db/database.py
index c36c5dc..bc78b01 100644
--- a/portato/db/database.py
+++ b/portato/db/database.py
@@ -59,13 +59,15 @@ class Database (object):
"""
raise NotImplentedError
- def get_cat (self, cat = None, byName = True):
+ def get_cat (self, cat = None, byName = True, showDisabled = False):
"""Returns the packages in the category.
@param cat: category to return the packages from; if None it defaults to C{ALL}
@type cat: string
@param byName: selects whether to return the list sorted by name or by installation
@type byName: boolean
+ @param showDisabled: should disabled packages be returned
+ @type showDisabled: boolean
@return: an iterator over the packages
@rtype: L{PkgData}<iterator>
"""
diff --git a/portato/db/dict.py b/portato/db/dict.py
index fd859dd..d7e2649 100644
--- a/portato/db/dict.py
+++ b/portato/db/dict.py
@@ -62,17 +62,20 @@ class DictDatabase (Database):
self._db[key].sort(key = self.__sort_key)
@lock
- def get_cat (self, cat = None, byName = True):
+ def get_cat (self, cat = None, byName = True, showDisabled = False):
if not cat:
cat = self.ALL
def get_pkgs():
if byName:
for pkg in self._db[cat]:
- yield pkg
+ if showDisabled or not pkg.disabled:
+ yield pkg
else:
ninst = []
for pkg in self._db[cat]:
+ if not showDisabled and pkg.disabled: continue
+
if pkg.inst:
yield pkg
else:
diff --git a/portato/db/sql.py b/portato/db/sql.py
index b406981..cac5c97 100644
--- a/portato/db/sql.py
+++ b/portato/db/sql.py
@@ -169,15 +169,19 @@ class SQLDatabase (Database):
connection.commit()
@con
- def get_cat (self, category = None, byName = True, connection = None):
+ def get_cat (self, category = None, byName = True, showDisabled = False, connection = None):
sort = "ORDER BY name"
if not byName:
sort = "ORDER BY inst DESC, name"
+ disabled = "1=1"
+ if not showDisabled:
+ disabled = "disabled = 0"
+
if not category or category == self.ALL:
- c = connection.execute("SELECT cat, name, inst, disabled FROM packages WHERE 1=1 %s %s" % (self.restrict, sort))
+ c = connection.execute("SELECT cat, name, inst, disabled FROM packages WHERE %s %s %s" % (disabled, self.restrict, sort))
else:
- c = connection.execute("SELECT cat, name, inst, disabled FROM packages WHERE cat = ? %s %s" % (self.restrict ,sort), (category,))
+ c = connection.execute("SELECT cat, name, inst, disabled FROM packages WHERE cat = ? AND %s %s %s" % (disabled, self.restrict ,sort), (category,))
for pkg in c:
yield PkgData(pkg["cat"], pkg["name"], pkg["inst"], pkg["disabled"])
@@ -191,7 +195,7 @@ class SQLDatabase (Database):
else:
where = "1 = 1"
- c = connection.execute("SELECT cat FROM packages WHERE %s %s GROUP BY cat" % (where, self.restrict))
+ c = connection.execute("SELECT cat FROM packages WHERE disabled = 0 AND %s %s GROUP BY cat" % (where, self.restrict))
l = c.fetchall()
c.close()
diff --git a/portato/gui/windows/main.py b/portato/gui/windows/main.py
index 472ddf0..9f3c123 100644
--- a/portato/gui/windows/main.py
+++ b/portato/gui/windows/main.py
@@ -746,18 +746,18 @@ class MainWindow (Window):
store.clear()
if name:
- for cat, pkg, is_inst, disabled in self.db.get_cat(name, self.sortPkgListByName):
- if disabled:
- warning(_("Package '%s/%s' is disabled."), cat, pkg)
+ for pkg in self.db.get_cat(name, self.sortPkgListByName):
+ if pkg.disabled:
+ warning(_("Package '%s/%s' is disabled."), pkg.cat, pkg.pkg)
continue
- if is_inst:
+ if pkg.inst:
icon = self.icons["installed"]
elif not self.showAll:
continue # ignore not installed packages
else:
icon = None
- store.append([icon, pkg, cat])
+ store.append([icon, pkg.pkg, pkg.cat])
def build_version_list (self):
store = gtk.ListStore(gtk.gdk.Pixbuf, str, str)