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

Method xpath_parent_pseudo

pyquery/cssselectpatch.py:342–353  ·  view source on GitHub ↗

Match all elements that contain other elements:: >>> from pyquery import PyQuery >>> d = PyQuery(' title ') >>> d('h1:parent') [ ] ..

(self, xpath)

Source from the content-addressed store, hash-verified

340 return xpath
341
342 def xpath_parent_pseudo(self, xpath):
343 """Match all elements that contain other elements::
344
345 >>> from pyquery import PyQuery
346 >>> d = PyQuery('<div><h1><span>title</span></h1><h1/></div>')
347 >>> d('h1:parent')
348 [<h1>]
349
350 ..
351 """
352 xpath.add_condition("count(child::*) > 0")
353 return xpath
354
355 def xpath_empty_pseudo(self, xpath):
356 """Match all elements that do not contain other elements::

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected