MCPcopy Create free account
hub / github.com/gawel/pyquery / next_until

Method next_until

pyquery/pyquery.py:479–497  ·  view source on GitHub ↗

>>> h = ''' ... Greeting 1 ... Hello! World! ... Greeting 2 Bye! ... ''' >>> d = PyQuery(h) >>> d('h2:first').nextUntil('h2') [ , ]

(self, selector, filter_=None)

Source from the content-addressed store, hash-verified

477
478 @with_camel_case_alias
479 def next_until(self, selector, filter_=None):
480 """
481 >>> h = '''
482 ... <h2>Greeting 1</h2>
483 ... <p>Hello!</p><p>World!</p>
484 ... <h2>Greeting 2</h2><p>Bye!</p>
485 ... ''&#x27;
486 >>> d = PyQuery(h)
487 >>> d('h2:first').nextUntil('h2')
488 [<p>, <p>]
489 """
490 return self._filter_only(
491 filter_, [
492 e
493 for q in itertools.takewhile(
494 lambda q: not q.is_(selector), self.next_all().items())
495 for e in q
496 ]
497 )
498
499 def _prev_all(self):
500 return [e for e in self._traverse('getprevious')]

Callers 1

test_next_untilMethod · 0.80

Calls 4

_filter_onlyMethod · 0.95
next_allMethod · 0.95
is_Method · 0.80
itemsMethod · 0.80

Tested by 1

test_next_untilMethod · 0.64