From 673913a2a8e743c44d58564d2d81cdf8fb8bea2e Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Wed, 6 Apr 2011 17:39:04 +0900 Subject: [PATCH] fix group tree when no cards use a group --- anki/deck.py | 3 ++- anki/sched.py | 2 +- anki/utils.py | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/anki/deck.py b/anki/deck.py index bef46d789..7757cdbf3 100644 --- a/anki/deck.py +++ b/anki/deck.py @@ -13,7 +13,8 @@ from anki.media import MediaRegistry from anki.consts import * import anki.latex # sets up hook -import anki.cards, anki.facts, anki.models, anki.template, anki.cram +import anki.cards, anki.facts, anki.models, anki.template, anki.cram, \ + anki.groups # Settings related to queue building. These may be loaded without the rest of # the config to check due counts faster on mobile clients. diff --git a/anki/sched.py b/anki/sched.py index 2a1f7e539..8369d27bb 100644 --- a/anki/sched.py +++ b/anki/sched.py @@ -124,7 +124,7 @@ sum(case when queue = 2 and due <= ? then 1 else 0 end), sum(case when queue = 0 then 1 else 0 end) from cards group by gid""", self.today): gids[gid] = [all, rev, new] - return [[name, gid]+gids[gid] for (gid, name) in + return [[name, gid]+gids.get(gid, [0, 0, 0]) for (gid, name) in self.deck.db.execute( "select id, name from groups order by name")] diff --git a/anki/utils.py b/anki/utils.py index 2d6722b15..e69981504 100644 --- a/anki/utils.py +++ b/anki/utils.py @@ -202,7 +202,7 @@ def joinTags(tags): return u" %s " % u" ".join(tags) def canonifyTags(tags): - "Strip leading/trailing/superfluous commas and duplicates." + "Strip leading/trailing/superfluous spaces and duplicates." tags = [t.lstrip(":") for t in set(tags)] return joinTags(sorted(tags))