コード例 #1
0
def idurl_to_id(idurl_text):
    """
    Translates IDURL into gobal id short form:
        http://somehost.com/alice.xml -> [email protected]
    """
    if not idurl_text:
        return idurl_text
    _, host, port, _, filename = nameurl.UrlParseFast(idurl_text)
    if filename.count('.'):
        username = filename.split('.')[0]
    else:
        username = filename
    if port:
        host = '%s_%s' % (host, port)
    return '%s@%s' % (username, host)
コード例 #2
0
def UrlToGlobalID(url, include_key=False):
    """
    """
    if not url:
        return url
    from lib import nameurl
    _, host, port, _, filename = nameurl.UrlParseFast(url)
    if filename.count('.'):
        username = filename.split('.')[0]
    else:
        username = filename
    if port:
        host = '%s_%s' % (host, port)
    if include_key:
        username = '******' % username
    return '%s@%s' % (username, host)
コード例 #3
0
def UrlToGlobalID(url, include_key=False):
    """
    """
    if not url:
        return url
    from lib import nameurl
    from userid import id_url
    if isinstance(url, id_url.ID_URL_FIELD):
        # small optimization
        return url.to_id()
    _, host, port, _, filename = nameurl.UrlParseFast(url)
    if filename.count('.'):
        username = filename.split('.')[0]
    else:
        username = filename
    if port:
        host = '%s_%s' % (host, port)
    if include_key:
        username = '******' % username
    return strng.to_text('%s@%s' % (username, host))