mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 08:46:37 -04:00
canonify tags after bulk update
This commit is contained in:
parent
93d80678f9
commit
d7b86da811
3 changed files with 8 additions and 3 deletions
|
@ -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):
|
||||
|
|
|
@ -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
|
||||
##############################################################################
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue