diff --git a/anki/deck.py b/anki/deck.py index 216d69f8b..b07e03eef 100644 --- a/anki/deck.py +++ b/anki/deck.py @@ -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 diff --git a/anki/utils.py b/anki/utils.py index 8348913be..58d96dd9a 100644 --- a/anki/utils.py +++ b/anki/utils.py @@ -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."