def parse_profile_from_hcard(hcard: str, handle: str):
    """
    Parse all the fields we can from a hCard document to get a Profile.

    :arg hcard: HTML hcard document (str)
    :arg handle: User handle in username@domain.tld format
    :returns: ``federation.entities.diaspora.entities.DiasporaProfile`` instance
    """
    from federation.entities.diaspora.entities import DiasporaProfile  # Circulars
    doc = html.fromstring(hcard)
    profile = DiasporaProfile(
        name=_get_element_text_or_none(doc, ".fn"),
        image_urls={
            "small": _get_element_attr_or_none(doc, ".entity_photo_small .photo", "src"),
            "medium": _get_element_attr_or_none(doc, ".entity_photo_medium .photo", "src"),
            "large": _get_element_attr_or_none(doc, ".entity_photo .photo", "src"),
        },
        public=True if _get_element_text_or_none(doc, ".searchable") == "true" else False,
        id=handle,
        handle=handle,
        guid=_get_element_text_or_none(doc, ".uid"),
        public_key=_get_element_text_or_none(doc, ".key"),
    )
    return profile
def parse_profile_from_hcard ( hcard : str , handle : str ) : from federation . entities . diaspora . entities import DiasporaProfile doc = html . fromstring ( hcard ) profile = DiasporaProfile ( name = _get_element_text_or_none ( doc , ".fn" ) , image_urls = { "small" : _get_element_attr_or_none ( doc , ".entity_photo_small .photo" , "src" ) , "medium" : _get_element_attr_or_none ( doc , ".entity_photo_medium .photo" , "src" ) , "large" : _get_element_attr_or_none ( doc , ".entity_photo .photo" , "src" ) , } , public = True if _get_element_text_or_none ( doc , ".searchable" ) == "true" else False , id = handle , handle = handle , guid = _get_element_text_or_none ( doc , ".uid" ) , public_key = _get_element_text_or_none ( doc , ".key" ) , ) return profile
Parse all the fields we can from a hCard document to get a Profile.

    :arg hcard: HTML hcard document (str)
    :arg handle: User handle in username@domain.tld format
    :returns: ``federation.entities.diaspora.entities.DiasporaProfile`` instance