def keep_last_occurrences(lst, key): | |
seen = set() | |
for idx in reversed(range(len(lst))): | |
item = lst[idx] | |
k = key(item) | |
if k in seen: | |
del lst[idx] | |
else: | |
seen.add(k) | |
return lst | |
def delete_duplicate_styles(list_styles_to_update, different_styles): | |
for s in list_styles_to_update: | |
for d in different_styles: | |
if s["doc"].name == d["doc"].name and s["list_style"].split(" : ")[0] == d["style"].name: | |
different_styles.remove(d) | |
return different_styles |