diff options
Diffstat (limited to 'portato/db/sql.py')
-rw-r--r-- | portato/db/sql.py | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/portato/db/sql.py b/portato/db/sql.py index e79a27d..fbc01e6 100644 --- a/portato/db/sql.py +++ b/portato/db/sql.py @@ -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() |