'Extract revision source and metadata from HTML.'

def extract_data(self, html):

    data = {}
    keys = (u'slug', u'title', u'id', u'created', u'creator', u'is_current', u'comment')
    parsed = pq(html)
    rev_info = parsed.find(u'div.revision-info    li    span')
    for (key, span) in zip(keys, rev_info):
        raw = span.text
        if (key == u'id'):
            value = int(raw)
        elif (key == u'created'):
            created = span.cssselect(u'time')[0].attrib[u'datetime']
            value = dateutil.parser.parse(created)
            value = value.replace(tzinfo=None)
        elif (key == u'is_current'):
            with override(self.locale):
                yes = gettext(u'Yes')
            value = (raw == yes.decode(u'utf8'))
        elif (key == u'comment'):
            value = (raw or u'')
        else:
            value = raw
        data[key] = value
    tags = []
    tag_links = parsed.find(u'ul.tags    li    a')
    for tag_link in tag_links:
        tags.append(tag_link.text)
    data[u'tags'] = tags
    source_elem = parsed.find(u'div#doc-source    pre')[0]
    data[u'content'] = source_elem.text
    return data
