예제 #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)
예제 #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)
예제 #3
0
파일: encoding.py 프로젝트: ENuge/yelp_uri
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)
예제 #4
0
파일: encoding.py 프로젝트: ENuge/yelp_uri
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)
예제 #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)
예제 #6
0
파일: encoding.py 프로젝트: ENuge/yelp_uri
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)
예제 #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)
예제 #8
0
파일: encoding.py 프로젝트: ENuge/yelp_uri
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)