canonify tags after bulk update

This commit is contained in:
Damien Elmes 2011-04-13 22:52:53 +09:00
parent 93d80678f9
commit d7b86da811
3 changed files with 8 additions and 3 deletions

View file

@ -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):

View file

@ -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
##############################################################################

View file

@ -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