mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12:21 -04:00
added search-hook for plugins using "search" scope
This commit is contained in:
parent
ff82aad50f
commit
b07254cb09
1 changed files with 6 additions and 0 deletions
|
@ -5,6 +5,7 @@
|
||||||
import re
|
import re
|
||||||
from anki.utils import ids2str, splitFields, joinFields, intTime
|
from anki.utils import ids2str, splitFields, joinFields, intTime
|
||||||
from anki.consts import *
|
from anki.consts import *
|
||||||
|
from anki.hooks import *
|
||||||
import sre_constants
|
import sre_constants
|
||||||
|
|
||||||
# Find
|
# Find
|
||||||
|
@ -27,6 +28,10 @@ class Finder(object):
|
||||||
self.search['rated'] = self._findRated
|
self.search['rated'] = self._findRated
|
||||||
self.search['tag'] = self._findTag
|
self.search['tag'] = self._findTag
|
||||||
|
|
||||||
|
|
||||||
|
def _loadSearchHookPlugins(self):
|
||||||
|
runHook("search", self.search)
|
||||||
|
|
||||||
def findCards(self, query, order=False):
|
def findCards(self, query, order=False):
|
||||||
"Return a list of card ids for QUERY."
|
"Return a list of card ids for QUERY."
|
||||||
tokens = self._tokenize(query)
|
tokens = self._tokenize(query)
|
||||||
|
@ -120,6 +125,7 @@ select distinct(n.id) from cards c, notes n where c.nid=n.id and """+preds
|
||||||
######################################################################
|
######################################################################
|
||||||
|
|
||||||
def _where(self, tokens):
|
def _where(self, tokens):
|
||||||
|
self._loadSearchHookPlugins()
|
||||||
# state and query
|
# state and query
|
||||||
s = dict(isnot=False, isor=False, join=False, q="", bad=False)
|
s = dict(isnot=False, isor=False, join=False, q="", bad=False)
|
||||||
args = []
|
args = []
|
||||||
|
|
Loading…
Reference in a new issue