def percent_encode_host(url):
        """ Convert the host of uri formatted with to_uri()
        to have a %-encoded host instead of punycode host
        The rest of url should be unchanged
        """

        # only continue if punycode encoded
        if 'xn--' not in url:
            return url

        parts = urlsplit(url)
        domain = parts.netloc.encode('utf-8')
        try:
            domain = domain.decode('idna')
            if six.PY2:
                domain = domain.encode('utf-8', 'ignore')
        except:
            # likely already encoded, so use as is
            pass

        domain = quote(domain)#, safe=r':\/')

        return urlunsplit((parts[0], domain, parts[2], parts[3], parts[4]))
def percent_encode_host ( url ) : if 'xn--' not in url : return url parts = urlsplit ( url ) domain = parts . netloc . encode ( 'utf-8' ) try : domain = domain . decode ( 'idna' ) if six . PY2 : domain = domain . encode ( 'utf-8' , 'ignore' ) except : pass domain = quote ( domain ) return urlunsplit ( ( parts [ 0 ] , domain , parts [ 2 ] , parts [ 3 ] , parts [ 4 ] ) )
Convert the host of uri formatted with to_uri()
        to have a %-encoded host instead of punycode host
        The rest of url should be unchanged