Remove duplicates on list merge

This commit is contained in:
Ruud
2012-04-15 10:44:21 +02:00
parent 98230dee32
commit dac9abc526
+8
View File
@@ -36,10 +36,18 @@ def mergeDicts(a, b):
stack.append((current_dst[key], current_src[key]))
elif isinstance(current_src[key], list) and isinstance(current_dst[key], list):
current_dst[key].extend(current_src[key])
current_dst[key] = removeListDuplicates(current_dst[key])
else:
current_dst[key] = current_src[key]
return dst
def removeListDuplicates(seq):
checked = []
for e in seq:
if e not in checked:
checked.append(e)
return checked
def flattenList(l):
if isinstance(l, list):
return sum(map(flattenList, l))