From d7b86da81197ba124a204315a737c10cf19dc9b5 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Wed, 13 Apr 2011 22:52:53 +0900 Subject: [PATCH] canonify tags after bulk update --- anki/facts.py | 2 +- anki/utils.py | 4 ++-- tests/test_deck.py | 5 +++++ 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/anki/facts.py b/anki/facts.py index 66f553b41..6df7539a2 100644 --- a/anki/facts.py +++ b/anki/facts.py @@ -4,7 +4,7 @@ import time from anki.errors import AnkiError -from anki.utils import stripHTMLMedia, fieldChecksum, intTime, \ +from anki.utils import fieldChecksum, intTime, \ joinFields, splitFields, ids2str, parseTags, canonifyTags, hasTag class Fact(object): diff --git a/anki/utils.py b/anki/utils.py index b7f38ee6a..c2f76a516 100644 --- a/anki/utils.py +++ b/anki/utils.py @@ -211,7 +211,7 @@ def addTags(addtags, tags): for tag in parseTags(addtags): if not hasTag(tag, currentTags): currentTags.append(tag) - return joinTags(currentTags) + return canonifyTags(currentTags) def delTags(deltags, tags): "Delete tags if they don't exists." @@ -225,7 +225,7 @@ def delTags(deltags, tags): # remove them for r in remove: currentTags.remove(r) - return joinTags(currentTags) + return canonifyTags(currentTags) # Fields ############################################################################## diff --git a/tests/test_deck.py b/tests/test_deck.py index cf9ee9b08..b5056fc83 100644 --- a/tests/test_deck.py +++ b/tests/test_deck.py @@ -184,3 +184,8 @@ def test_addDelTags(): f.load(); f2.load() assert "foo" in f.tags assert "foo" not in f2.tags + # should be canonified + deck.addTags([f.id], "foo aaa") + f.load() + assert f.tags[0] == "aaa" + assert len(f.tags) == 2