mirror of
https://github.com/ankitects/anki.git
synced 2025-09-19 06:22:22 -04:00
Use new backend filters in rename_tag()
This commit is contained in:
parent
34245e6f72
commit
bf0086d565
1 changed files with 4 additions and 3 deletions
|
@ -16,6 +16,7 @@ import re
|
||||||
from typing import Collection, List, Optional, Sequence, Tuple
|
from typing import Collection, List, Optional, Sequence, Tuple
|
||||||
|
|
||||||
import anki # pylint: disable=unused-import
|
import anki # pylint: disable=unused-import
|
||||||
|
from anki.rsbackend import FilterToSearchIn
|
||||||
from anki.utils import ids2str
|
from anki.utils import ids2str
|
||||||
|
|
||||||
|
|
||||||
|
@ -86,11 +87,11 @@ class TagManager:
|
||||||
|
|
||||||
def rename_tag(self, old: str, new: str) -> int:
|
def rename_tag(self, old: str, new: str) -> int:
|
||||||
"Rename provided tag, returning number of changed notes."
|
"Rename provided tag, returning number of changed notes."
|
||||||
escaped_name = re.sub(r"[*_\\]", r"\\\g<0>", old)
|
search = self.col.backend.filter_to_search(FilterToSearchIn(tag=old))
|
||||||
quote_escaped = escaped_name.replace('"', '\\"')
|
nids = self.col.find_notes(search)
|
||||||
nids = self.col.find_notes(f'tag:"{quote_escaped}"')
|
|
||||||
if not nids:
|
if not nids:
|
||||||
return 0
|
return 0
|
||||||
|
escaped_name = re.sub(r"[*_\\]", r"\\\g<0>", old)
|
||||||
return self.bulk_update(nids, escaped_name, new, False)
|
return self.bulk_update(nids, escaped_name, new, False)
|
||||||
|
|
||||||
# legacy routines
|
# legacy routines
|
||||||
|
|
Loading…
Reference in a new issue