Allow wildcard tag deletion
This commit is contained in:
parent
2539896b22
commit
12c98a21f0
@ -102,7 +102,7 @@ class TagManager:
|
|||||||
res = self.col.db.all(
|
res = self.col.db.all(
|
||||||
"select id, tags from notes where id in %s and (%s)" % (
|
"select id, tags from notes where id in %s and (%s)" % (
|
||||||
ids2str(ids), lim),
|
ids2str(ids), lim),
|
||||||
**dict([("_%d" % x, '%% %s %%' % y)
|
**dict([("_%d" % x, '%% %s %%' % y.replace('*', '%'))
|
||||||
for x, y in enumerate(newTags)]))
|
for x, y in enumerate(newTags)]))
|
||||||
# update tags
|
# update tags
|
||||||
nids = []
|
nids = []
|
||||||
@ -139,13 +139,16 @@ class TagManager:
|
|||||||
return self.join(self.canonify(currentTags))
|
return self.join(self.canonify(currentTags))
|
||||||
|
|
||||||
def remFromStr(self, deltags, tags):
|
def remFromStr(self, deltags, tags):
|
||||||
"Delete tags if they don't exists."
|
"Delete tags if they exist."
|
||||||
|
def wildcard(pat, str):
|
||||||
|
return '*' in pat and re.search(
|
||||||
|
pat.replace('*', '.*'), str, re.IGNORECASE)
|
||||||
currentTags = self.split(tags)
|
currentTags = self.split(tags)
|
||||||
for tag in self.split(deltags):
|
for tag in self.split(deltags):
|
||||||
# find tags, ignoring case
|
# find tags, ignoring case
|
||||||
remove = []
|
remove = []
|
||||||
for tx in currentTags:
|
for tx in currentTags:
|
||||||
if tag.lower() == tx.lower():
|
if (tag.lower() == tx.lower()) or wildcard(tag, tx):
|
||||||
remove.append(tx)
|
remove.append(tx)
|
||||||
# remove them
|
# remove them
|
||||||
for r in remove:
|
for r in remove:
|
||||||
|
Loading…
Reference in New Issue
Block a user