Matches all elements with an index below the given one:: >>> from pyquery import PyQuery >>> d = PyQuery(' ') >>> d('h1:lt(1)') [ ] ..
(self, xpath, function)
| 404 | return xpath |
| 405 | |
| 406 | def xpath_lt_function(self, xpath, function): |
| 407 | """Matches all elements with an index below the given one:: |
| 408 | |
| 409 | >>> from pyquery import PyQuery |
| 410 | >>> d = PyQuery('<div><h1 class="first"/><h1 class="last"/></div>') |
| 411 | >>> d('h1:lt(1)') |
| 412 | [<h1.first>] |
| 413 | |
| 414 | .. |
| 415 | """ |
| 416 | if function.argument_types() != ['NUMBER']: |
| 417 | raise ExpressionError( |
| 418 | "Expected a single integer for :gt(), got %r" % ( |
| 419 | function.arguments,)) |
| 420 | |
| 421 | value = int(function.arguments[0].value) |
| 422 | xpath.add_post_condition('position() < %s' % (value + 1)) |
| 423 | return xpath |
| 424 | |
| 425 | def xpath_contains_function(self, xpath, function): |
| 426 | """Matches all elements that contain the given text |
nothing calls this directly
no test coverage detected