mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Add a has_matches() method for convenience
This commit is contained in:
parent
880391ce34
commit
e7caf265c1
@ -141,6 +141,7 @@ class Select(object):
|
|||||||
else:
|
else:
|
||||||
self.ignore_inappropriate_pseudo_classes = frozenset()
|
self.ignore_inappropriate_pseudo_classes = frozenset()
|
||||||
|
|
||||||
|
# External API {{{
|
||||||
def invalidate_caches(self):
|
def invalidate_caches(self):
|
||||||
'Invalidate all caches. You must call this before using this object if you have made changes to the HTML tree'
|
'Invalidate all caches. You must call this before using this object if you have made changes to the HTML tree'
|
||||||
self._element_map = None
|
self._element_map = None
|
||||||
@ -165,6 +166,13 @@ class Select(object):
|
|||||||
yield item
|
yield item
|
||||||
seen.add(item)
|
seen.add(item)
|
||||||
|
|
||||||
|
def has_matches(self, selector):
|
||||||
|
'Return True iff selector matches at least one item in the tree'
|
||||||
|
for elem in self(selector):
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
# }}}
|
||||||
|
|
||||||
def iterparsedselector(self, parsed_selector):
|
def iterparsedselector(self, parsed_selector):
|
||||||
type_name = type(parsed_selector).__name__
|
type_name = type(parsed_selector).__name__
|
||||||
try:
|
try:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user