Same as eval_xpath, check if the result is a list Args: * element (ElementBase): [description] * xpath_spec (str|lxml.etree.XPath): XPath as a str or lxml.etree.XPath * min_len (int, optional): [description]. Defaults to None. Raises: * TypeError: Raise when
(element, xpath_spec, min_len=None)
| 563 | |
| 564 | |
| 565 | def eval_xpath_list(element, xpath_spec, min_len=None): |
| 566 | """Same as eval_xpath, check if the result is a list |
| 567 | |
| 568 | Args: |
| 569 | * element (ElementBase): [description] |
| 570 | * xpath_spec (str|lxml.etree.XPath): XPath as a str or lxml.etree.XPath |
| 571 | * min_len (int, optional): [description]. Defaults to None. |
| 572 | |
| 573 | Raises: |
| 574 | * TypeError: Raise when xpath_spec is neither a str nor a lxml.etree.XPath |
| 575 | * SearxXPathSyntaxException: Raise when there is a syntax error in the XPath |
| 576 | * SearxEngineXPathException: raise if the result is not a list |
| 577 | |
| 578 | Returns: |
| 579 | * result (bool, float, list, str): Results. |
| 580 | """ |
| 581 | result = eval_xpath(element, xpath_spec) |
| 582 | if not isinstance(result, list): |
| 583 | raise SearxEngineXPathException(xpath_spec, 'the result is not a list') |
| 584 | if min_len is not None and min_len > len(result): |
| 585 | raise SearxEngineXPathException(xpath_spec, 'len(xpath_str) < ' + str(min_len)) |
| 586 | return result |
| 587 | |
| 588 | |
| 589 | def eval_xpath_getindex(elements, xpath_spec, index, default=NOTSET): |
no test coverage detected