Atom 内の ID によるダイジェスト

rss_sum が要るなら atom_sum も当然要るよねと.

def atom_sum(s):
    from xml.dom import pulldom
    from hashlib import md5
    acc = []
    p = pulldom.parseString(xml_encoding_hack(s))
    for (e, n) in p:
        if (e == pulldom.START_ELEMENT) and (n.tagName == 'entry'):
            p.expandNode(n)
            l = n.getElementsByTagName('id')
            acc.append(l[0].firstChild.data)
    return md5('\0'.join(acc)).hexdigest()