Ejemplo n.º 1
0
def encode_uri(uri):
    """Given a (presumed decoded) uri, return a well-encoded uri suitable for an html href."""
    uri = urlsplit(uri)

    new_uri = encode_split_uri(uri)

    return urlunsplit(new_uri)
Ejemplo n.º 2
0
def decode_uri(uri):
    """Given a uri, return a decoded uri suitable for displaying to users."""
    uri = urlsplit(uri)

    new_uri = decode_split_uri(uri)

    return urlunsplit(new_uri)
Ejemplo n.º 3
0
def decode_uri(uri):
    """Given a uri, return a decoded uri suitable for displaying to users."""
    uri = urlsplit(uri)

    new_uri = decode_split_uri(uri)

    return urlunsplit(new_uri)
Ejemplo n.º 4
0
def encode_uri(uri):
    """Given a (presumed decoded) uri, return a well-encoded uri suitable for an html href."""
    uri = urlsplit(uri)

    new_uri = encode_split_uri(uri)

    return urlunsplit(new_uri)
Ejemplo n.º 5
0
def recode_uri(uri):
    """Take an unknown uri and return a well-encoded uri suitable for an html href.
    This is essentially equivalent to encode(decode(uri)), but a little more efficient.
    """
    uri = urlsplit(uri)

    new_uri = recode_split_uri(uri)

    return urlunsplit(new_uri)
Ejemplo n.º 6
0
def recode_uri(uri):
    """Take an unknown uri and return a well-encoded uri suitable for an html href.
    This is essentially equivalent to encode(decode(uri)), but a little more efficient.
    """
    uri = urlsplit(uri)

    new_uri = recode_split_uri(uri)

    return urlunsplit(new_uri)
Ejemplo n.º 7
0
def _emailsplit(email):
    """We don't support the full RFC6068 here, just a single email.
    To simplify processing, we treat the email as a username@hostname,
    rather than uri-path as specified.

    This is rather hackity. To do it the Right Way would probably necessitate a whole new namespace.
    """
    email = urlsplit(email)

    if email.path:
        username, sep, hostname = email.path.rpartition('@')
        if not sep:
            username = None
        return email.replace(username=username, hostname=hostname, path='')
    else:
        return email
Ejemplo n.º 8
0
def _emailsplit(email):
    """We don't support the full RFC6068 here, just a single email.
    To simplify processing, we treat the email as a username@hostname,
    rather than uri-path as specified.

    This is rather hackity. To do it the Right Way would probably necessitate a whole new namespace.
    """
    email = urlsplit(email)

    if email.path:
        username, sep, hostname = email.path.rpartition('@')
        if not sep:
            username = None
        return email.replace(username=username, hostname=hostname, path='')
    else:
        return email