Exemplo 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)
Exemplo 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)
Exemplo 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)
Exemplo 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)
Exemplo 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)
Exemplo 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)
Exemplo n.º 7
0
def _emailunsplit(split_email):
    """Given a result from _emailsplit, return an email string."""
    # I know. Gross. I don't see a better way.
    email_path = '@'.join(s
                          for s in (split_email.username, split_email.hostname)
                          if s is not None)
    split_email = split_email.replace(username=None,
                                      hostname=None,
                                      path=email_path)
    return urlunsplit(split_email)
Exemplo n.º 8
0
def _emailunsplit(split_email):
    """Given a result from _emailsplit, return an email string."""
    # I know. Gross. I don't see a better way.
    email_path = '@'.join(s for s in (split_email.username, split_email.hostname) if s is not None)
    split_email = split_email.replace(username=None, hostname=None, path=email_path)
    return urlunsplit(split_email)