def iri2uri(uri):
 if isinstance(uri, str):
  (scheme, authority, path, query, fragment) = urllib.parse.urlsplit(uri)
  authority = authority.encode('idna').decode('utf-8')
  uri = urllib.parse.urlunsplit((scheme, authority, path, query, fragment))
  uri = ''.join([encode(c) for c in uri])
 return uri

def iri2uri ( uri ) : if isinstance ( uri , str ) : ( scheme , authority , path , query , fragment ) = urllib . parse . urlsplit ( uri ) authority = authority . encode ( 'idna' ) . decode ( 'utf-8' ) uri = urllib . parse . urlunsplit ( ( scheme , authority , path , query , fragment ) ) uri = '' . join ( [ encode ( c ) for c in uri ] ) return uri
convert an iri to a uri .