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:
|
||||
self.ignore_inappropriate_pseudo_classes = frozenset()
|
||||
|
||||
# External API {{{
|
||||
def invalidate_caches(self):
|
||||
'Invalidate all caches. You must call this before using this object if you have made changes to the HTML tree'
|
||||
self._element_map = None
|
||||
@ -165,6 +166,13 @@ class Select(object):
|
||||
yield 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):
|
||||
type_name = type(parsed_selector).__name__
|
||||
try:
|
||||
|
Loading…
x
Reference in New Issue
Block a user