Add ignore_duplicate option for crazy modules
This commit is contained in:
parent
cdf2996d57
commit
fe5bfee255
1 changed files with 7 additions and 4 deletions
|
|
@ -600,6 +600,7 @@ class AbstractElement(object):
|
||||||
class ListElement(AbstractElement):
|
class ListElement(AbstractElement):
|
||||||
item_xpath = None
|
item_xpath = None
|
||||||
flush_at_end = False
|
flush_at_end = False
|
||||||
|
ignore_duplicate = False
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(ListElement, self).__init__(*args, **kwargs)
|
super(ListElement, self).__init__(*args, **kwargs)
|
||||||
|
|
@ -650,9 +651,11 @@ class ListElement(AbstractElement):
|
||||||
def store(self, obj):
|
def store(self, obj):
|
||||||
if obj.id:
|
if obj.id:
|
||||||
if obj.id in self.objects:
|
if obj.id in self.objects:
|
||||||
self.logger.error('There are two objects with the same ID! %s' % obj.id)
|
if self.ignore_duplicate:
|
||||||
|
self.logger.warning('There are two objects with the same ID! %s' % obj.id)
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
|
raise DataError('There are two objects with the same ID! %s' % obj.id)
|
||||||
self.objects[obj.id] = obj
|
self.objects[obj.id] = obj
|
||||||
return obj
|
return obj
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue