Commit 3f2d8ae1 authored by Laurent Bachelier's avatar Laurent Bachelier 🐧 Committed by Romain Bignon

Allow for a custom element finder

And end up with less duplicate code!
parent d6213643
......@@ -662,16 +662,23 @@ class ListElement(AbstractElement):
return self.__iter__()
def __iter__(self):
self.parse(self.el)
def find_elements(self):
"""
Get the nodes that will have to be processed.
This method can be overridden if xpath filters are not
sufficient.
"""
if self.item_xpath is not None:
for el in self.el.xpath(self.item_xpath):
for obj in self.handle_element(el):
if not self.flush_at_end:
yield obj
yield el
else:
for obj in self.handle_element(self.el):
yield self.el
def __iter__(self):
self.parse(self.el)
for el in self.find_elements():
for obj in self.handle_element(el):
if not self.flush_at_end:
yield obj
......
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