summaryrefslogtreecommitdiff
path: root/portato/db/sql.py
diff options
context:
space:
mode:
Diffstat (limited to 'portato/db/sql.py')
-rw-r--r--portato/db/sql.py19
1 files changed, 17 insertions, 2 deletions
diff --git a/portato/db/sql.py b/portato/db/sql.py
index db66764..fbc01e6 100644
--- a/portato/db/sql.py
+++ b/portato/db/sql.py
@@ -166,7 +166,7 @@ class SQLDatabase (Database):
def populate (self, category = None, connection = None):
def _get():
# get the lists
- inst = system.find_packages(pkgSet = system.SET_INSTALLED, key=category, with_version = False)
+ inst = set(system.find_packages(pkgSet = system.SET_INSTALLED, key=category, with_version = False))
for p in system.find_packages(key = category, with_version = False):
cat, pkg = p.split("/")
@@ -213,12 +213,26 @@ class SQLDatabase (Database):
for cat in l:
yield cat["cat"]
+ def generate_cat_expr (self, cat):
+ """
+ Generates an expression from a category name to match all packages of the category.
+
+ E.g. as SQLDatabase uses regexps internally, return cat/*
+
+ @param cat: the category
+ @type cat: string
+
+ @returns: expression
+ """
+
+ return cat+"/*"
+
@con
def reload (self, cat = None, connection = None):
if cat:
connection.execute("DELETE FROM packages WHERE cat = ?", (cat,))
connection.commit()
- self.populate(cat+"/*", connection = connection)
+ self.populate(self.generate_cat_expr(cat), connection = connection)
else:
connection.execute("DELETE FROM packages")
connection.commit()
@@ -247,3 +261,4 @@ class SQLDatabase (Database):
self._restrict = "AND (name LIKE '%%%(restrict)s%%' OR cat LIKE '%(restrict)s%%')" % {"restrict":restrict}
restrict = property(get_restrict, set_restrict)
+ con = staticmethod(con)