def _feed_entry_from_annotation(
        annotation, annotation_url, annotation_api_url=None):
    """Return an Atom feed entry for the given annotation.

    :returns: A logical representation of the Atom feed entry as a dict,
        containing all of the data that a template would need to render the
        feed item to XML.
    :rtype: dict

    """
    try:
        name = util.user.split_user(annotation["user"])["username"]
    except __HOLE__:
        name = annotation["user"]
    entry = {
        "id": h.feeds.util.tag_uri_for_annotation(
            annotation.annotation, annotation_url),
        "author": {"name": name},
        "title": annotation.title,
        "updated": annotation["updated"],
        "published": annotation["created"],
        "content": annotation.description,
        "links": [
            {"rel": "alternate", "type": "text/html",
             "href": annotation_url(annotation.annotation)},
        ]
    }
    if annotation_api_url:
        entry["links"].append(
            {"rel": "alternate", "type": "application/json",
             "href": annotation_api_url(annotation.annotation)}
        )
    entry["links"].extend(
        [{"rel": "related", "href": link} for link in annotation.target_links])

    return entry
dataset/ETHPy150Open hypothesis/h/h/feeds/atom.py/_feed_entry_from_annotation