The new woob repository is here: https://gitlab.com/woob/woob. This gitlab will be removed soon.

The new woob repository is here: https://gitlab.com/woob/woob. This gitlab will be removed soon.

Commit af7286cf authored by Vincent Ardisson's avatar Vincent Ardisson Committed by Vincent A

weboob.browser.filters.standard: in case of list Base returns first element

The use case of this patch is being able to perform:

   Base(TableCell('foo'), CleanText('./span'))

It was impossible without because CleanText was called with a list of
matching elements, instead of a single lxml element.

Not sure if it's the right way to fix the problem. Other ways include:
- modifying TableCell to return the element instead of a list of
elements
- modifying CleanText to accept a list of elements
- introducing another filter to take only the first element
parent 9c371e85
......@@ -119,6 +119,9 @@ class Base(Filter):
def __call__(self, item):
base = self.select(self.base, item)
if isinstance(base, list):
assert len(base) == 1, 'If using a list, there must be one element only'
base = base[0]
return self.select(self.selector, base)
def __init__(self, base, selector=None, default=_NO_DEFAULT):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment