From fe5bfee255ab01748e04c65c939233331c9d68b8 Mon Sep 17 00:00:00 2001 From: Florent Date: Thu, 24 Apr 2014 16:16:50 +0200 Subject: [PATCH] Add ignore_duplicate option for crazy modules --- weboob/tools/browser2/page.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/weboob/tools/browser2/page.py b/weboob/tools/browser2/page.py index 03e612df..e1cf0d18 100644 --- a/weboob/tools/browser2/page.py +++ b/weboob/tools/browser2/page.py @@ -600,6 +600,7 @@ class AbstractElement(object): class ListElement(AbstractElement): item_xpath = None flush_at_end = False + ignore_duplicate = False def __init__(self, *args, **kwargs): super(ListElement, self).__init__(*args, **kwargs) @@ -650,10 +651,12 @@ class ListElement(AbstractElement): def store(self, obj): if obj.id: if obj.id in self.objects: - self.logger.error('There are two objects with the same ID! %s' % obj.id) - return - else: - self.objects[obj.id] = obj + if self.ignore_duplicate: + self.logger.warning('There are two objects with the same ID! %s' % obj.id) + return + else: + raise DataError('There are two objects with the same ID! %s' % obj.id) + self.objects[obj.id] = obj return obj def handle_element(self, el):