export SearchTerm from collection.py, and avoid exporting embedded items

This commit is contained in:
Damien Elmes 2021-01-30 11:01:11 +10:00
parent 73b897c754
commit 5e6dd54c8e
3 changed files with 12 additions and 14 deletions

View File

@ -16,6 +16,7 @@ import anki.find
import anki.latex # sets up hook
import anki.template
from anki import hooks
from anki.backend_pb2 import SearchTerm
from anki.cards import Card
from anki.config import ConfigManager
from anki.consts import *
@ -30,14 +31,11 @@ from anki.rsbackend import ( # pylint: disable=unused-import
BackendNoteTypeID,
ConcatSeparator,
DBError,
DupeIn,
Flag,
FormatTimeSpanContext,
InvalidInput,
NoteIDs,
Progress,
RustBackend,
SearchTerm,
pb,
)
from anki.sched import Scheduler as V1Scheduler
@ -789,7 +787,7 @@ table.review-log {{ {revlog_style} }}
def dupe_search_term(mid: int, text: str) -> SearchTerm:
"""Helper function for building a DupeIn message."""
dupe_in = DupeIn(mid=BackendNoteTypeID(ntid=mid), text=text)
dupe_in = SearchTerm.DupeIn(mid=BackendNoteTypeID(ntid=mid), text=text)
return SearchTerm(dupe=dupe_in)

View File

@ -47,9 +47,6 @@ TagTreeNode = pb.TagTreeNode
NoteType = pb.NoteType
DeckTreeNode = pb.DeckTreeNode
StockNoteType = pb.StockNoteType
SearchTerm = pb.SearchTerm
Flag = pb.SearchTerm.Flag
DupeIn = pb.SearchTerm.DupeIn
NoteIDs = pb.NoteIDs
BackendNoteTypeID = pb.NoteTypeID
ConcatSeparator = pb.ConcatenateSearchesIn.Separator

View File

@ -13,7 +13,7 @@ from typing import List, Optional, Sequence, Tuple, cast
import aqt
import aqt.forms
from anki.cards import Card
from anki.collection import Collection, Flag, InvalidInput, SearchTerm, nid_search_term
from anki.collection import Collection, InvalidInput, SearchTerm, nid_search_term
from anki.consts import *
from anki.lang import without_unicode_isolation
from anki.models import NoteType
@ -1041,12 +1041,15 @@ QTableView {{ gridline-color: {grid} }}
SearchTerm(card_state=SearchTerm.CardState.BURIED),
),
None,
(tr(TR.ACTIONS_RED_FLAG), SearchTerm(flag=Flag.RED)),
(tr(TR.ACTIONS_ORANGE_FLAG), SearchTerm(flag=Flag.ORANGE)),
(tr(TR.ACTIONS_GREEN_FLAG), SearchTerm(flag=Flag.GREEN)),
(tr(TR.ACTIONS_BLUE_FLAG), SearchTerm(flag=Flag.BLUE)),
(tr(TR.BROWSING_NO_FLAG), SearchTerm(flag=Flag.WITHOUT)),
(tr(TR.BROWSING_ANY_FLAG), SearchTerm(flag=Flag.ANY)),
(tr(TR.ACTIONS_RED_FLAG), SearchTerm(flag=SearchTerm.Flag.RED)),
(
tr(TR.ACTIONS_ORANGE_FLAG),
SearchTerm(flag=SearchTerm.Flag.ORANGE),
),
(tr(TR.ACTIONS_GREEN_FLAG), SearchTerm(flag=SearchTerm.Flag.GREEN)),
(tr(TR.ACTIONS_BLUE_FLAG), SearchTerm(flag=SearchTerm.Flag.BLUE)),
(tr(TR.BROWSING_NO_FLAG), SearchTerm(flag=SearchTerm.Flag.WITHOUT)),
(tr(TR.BROWSING_ANY_FLAG), SearchTerm(flag=SearchTerm.Flag.ANY)),
)
)
)