mirror of
https://github.com/ankitects/anki.git
synced 2025-09-20 06:52:21 -04:00
add user tags list, sort tags in canonify
This commit is contained in:
parent
8f2efd83b3
commit
cd64b0db9e
2 changed files with 7 additions and 2 deletions
|
@ -14,7 +14,8 @@ from anki.db import *
|
||||||
from anki.lang import _
|
from anki.lang import _
|
||||||
from anki.errors import DeckAccessError
|
from anki.errors import DeckAccessError
|
||||||
from anki.stdmodels import BasicModel
|
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.history import CardHistoryEntry
|
||||||
from anki.models import Model, CardModel, formatQA
|
from anki.models import Model, CardModel, formatQA
|
||||||
from anki.stats import dailyStats, globalStats, genToday
|
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 a hash listing tags in model & fact."
|
||||||
return list(set(parseTags(",".join([x[1] for x in self.tagsList()]))))
|
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):
|
def factTags(self, ids):
|
||||||
return self.s.all("""
|
return self.s.all("""
|
||||||
select id, tags from facts
|
select id, tags from facts
|
||||||
|
|
|
@ -113,7 +113,7 @@ def joinTags(tags):
|
||||||
|
|
||||||
def canonifyTags(tags):
|
def canonifyTags(tags):
|
||||||
"Strip leading/trailing/superfluous commas."
|
"Strip leading/trailing/superfluous commas."
|
||||||
return joinTags(parseTags(tags))
|
return joinTags(sorted(set(parseTags(tags))))
|
||||||
|
|
||||||
def findTag(tag, tags):
|
def findTag(tag, tags):
|
||||||
"True if TAG is in TAGS. Ignore case."
|
"True if TAG is in TAGS. Ignore case."
|
||||||
|
|
Loading…
Reference in a new issue