'This creates merged VCards, grouping by uid/e-mail and key'

@classmethod
def vcards_merged(cls, keys, vcards):

    new_vcards = []
    for (key_id, key) in keys.iteritems():
        if cls.key_is_useless(key):
            continue
        vcls = [cls.key_vcl(key_id, key)]
        card = None
        emails = []
        for uid in key.get('uids', []):
            if uid.get('email'):
                vcls.append(VCardLine(name='email', value=uid['email']))
                card = (card or vcards.get(uid['email']))
                emails.append(uid['email'])
            if uid.get('name'):
                name = uid['name']
                vcls.append(VCardLine(name='fn', value=name))
        if (card and emails):
            card.add(*vcls)
        elif emails:
            card = MailpileVCard(*vcls)
            card.add(VCardLine(name='x-gpg-mrgid', value=key_id))
            for email in emails:
                vcards[email] = card
            new_vcards.append(card)
    return new_vcards
