+ print "Merge duplicate buttons (if any)..."
+ hash = {}
+ for b in buttons:
+ if b.slug not in hash:
+ hash[b.slug] = b
+ continue
+
+ # duplicate button
+ print "Found duplicate of '%s'" % b.slug
+ a = hash[b.slug]
+
+ remove_duplicate = True
+ if a.params != b.params:
+ print "Conflicting params for duplicate of '%s'." % b.slug
+ print "Groups will be joined, but won't remove duplicates."
+ remove_duplicate = False
+
+ for g in b.group.all():
+ a.group.add(g)
+
+ b.group.clear()
+
+ a.save()
+ if remove_duplicate:
+ b.delete()