From 0362821fb60c9a194463ff064d79a8434c72aa51 Mon Sep 17 00:00:00 2001 From: Florent Date: Wed, 19 Mar 2014 16:46:46 +0100 Subject: [PATCH] Introduce the new Attr filter --- weboob/tools/browser2/filters.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/weboob/tools/browser2/filters.py b/weboob/tools/browser2/filters.py index 867af373..68e9c576 100644 --- a/weboob/tools/browser2/filters.py +++ b/weboob/tools/browser2/filters.py @@ -244,3 +244,12 @@ class Time(Filter): mm = int(m.groupdict()['mm'] or 0) ss = int(m.groupdict()['ss'] or 0) return datetime.time(hh, mm, ss) + +class Attr(_Filter): + def __init__(self, xpath, attr): + super(Attr, self).__init__() + self.xpath = xpath + self.attr = attr + + def __call__(self, item): + return item.xpath(self.xpath)[0].attrib[self.attr]