mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Better __str__ for search objects
This commit is contained in:
parent
9e640df255
commit
ffe4e65ef2
@ -97,6 +97,11 @@ class Search(object):
|
|||||||
self._regex = regex.compile(expr, flags)
|
self._regex = regex.compile(expr, flags)
|
||||||
return self._regex
|
return self._regex
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
from collections import namedtuple
|
||||||
|
s = ('text', 'mode', 'case_sensitive', 'backwards')
|
||||||
|
return str(namedtuple('Search', s)(*tuple(getattr(self, x) for x in s)))
|
||||||
|
|
||||||
|
|
||||||
class SearchFinished(object):
|
class SearchFinished(object):
|
||||||
|
|
||||||
@ -143,6 +148,11 @@ class SearchResult(object):
|
|||||||
def is_or_is_after(self, result_from_js):
|
def is_or_is_after(self, result_from_js):
|
||||||
return result_from_js['spine_idx'] == self.spine_idx and self.index >= result_from_js['index'] and result_from_js['text'] == self.text
|
return result_from_js['spine_idx'] == self.spine_idx and self.index >= result_from_js['index'] and result_from_js['text'] == self.text
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
from collections import namedtuple
|
||||||
|
s = self.__slots__[:-1]
|
||||||
|
return str(namedtuple('SearchResult', s)(*tuple(getattr(self, x) for x in s)))
|
||||||
|
|
||||||
|
|
||||||
@lru_cache(maxsize=None)
|
@lru_cache(maxsize=None)
|
||||||
def searchable_text_for_name(name):
|
def searchable_text_for_name(name):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user