Making the search a bit more pythonic
authorepage <eopage@byu.net>
Sat, 16 May 2009 18:02:01 +0000 (18:02 +0000)
committerepage <eopage@byu.net>
Sat, 16 May 2009 18:02:01 +0000 (18:02 +0000)
git-svn-id: file:///svnroot/quicknote/trunk@38 bb7704e3-badb-4cfa-9ab3-9374dc87eaa2

src/libkopfzeile.py

index 0b77f6f..6b0a7ba 100644 (file)
@@ -87,15 +87,13 @@ class Kopfzeile(gtk.HBox):
                i = 0
                active = -1
                cats = []
-               while i < n:
-                       if (model[i][0] == category):
-                               #self.categoryCombo.set_active(i)
+               for i, row in enumerate(model):
+                       if row[0] == category:
                                active = i
-                       if (model[i][0]!= "%"):
-                               cats.append(model[i][0])
-                       i += 1
+                       if row[0] != "%":
+                               cats.append(row[0])
 
-               if (active == -1) and (category!= "%"):
+               if active == -1 and category != "%":
                        self.categoryCombo.append_text(category)
                        sql = "INSERT INTO categories  (id, liste) VALUES (0, ?)"
                        self._db.speichereSQL(sql, (category, ))