add user tags list, sort tags in canonify

This commit is contained in:
Damien Elmes 2008-11-28 18:53:04 +09:00
parent 8f2efd83b3
commit cd64b0db9e
2 changed files with 7 additions and 2 deletions

View file

@ -14,7 +14,8 @@ from anki.db import *
from anki.lang import _
from anki.errors import DeckAccessError
from anki.stdmodels import BasicModel
from anki.utils import parseTags, tidyHTML, genID, ids2str, hexifyID, canonifyTags
from anki.utils import parseTags, tidyHTML, genID, ids2str, hexifyID, \
canonifyTags, joinTags
from anki.history import CardHistoryEntry
from anki.models import Model, CardModel, formatQA
from anki.stats import dailyStats, globalStats, genToday
@ -1254,6 +1255,10 @@ and cards.factId = facts.id""")
"Return a hash listing tags in model & fact."
return list(set(parseTags(",".join([x[1] for x in self.tagsList()]))))
def allUserTags(self):
return sorted(list(set(parseTags(joinTags(self.s.column0(
"select tags from facts"))))))
def factTags(self, ids):
return self.s.all("""
select id, tags from facts

View file

@ -113,7 +113,7 @@ def joinTags(tags):
def canonifyTags(tags):
"Strip leading/trailing/superfluous commas."
return joinTags(parseTags(tags))
return joinTags(sorted(set(parseTags(tags))))
def findTag(tag, tags):
"True if TAG is in TAGS. Ignore case."