add utils for adding/removing tags

This commit is contained in:
Damien Elmes 2011-04-16 01:59:00 +09:00
parent f7c11f5771
commit ce0df2652f
2 changed files with 13 additions and 1 deletions

View file

@ -117,6 +117,18 @@ insert or replace into facts values (?, ?, ?, ?, ?, ?, ?, ?, ?)""",
def stringTags(self):
return canonifyTags(self.tags)
def delTag(self, tag):
rem = []
for t in self.tags:
if t.lower() == tag.lower():
rem.append(t)
for r in rem:
self.tags.remove(r)
def addTag(self, tag):
# duplicates will be stripped on save
self.tags.append(tag)
# Unique/duplicate checks
##################################################

View file

@ -537,7 +537,7 @@ queue = 2 %s and due <= :lim order by %s limit %d""" % (
(card.lapses-lf) % (max(lf/2, 1)) == 0):
# add a leech tag
f = card.fact()
f.tags.append("leech")
f.addTag("leech")
f.flush()
# handle
if conf['leechAction'][0] == 0: