def host_tuple(url):
 if (not url.isValid()):
  raise InvalidUrlError(url)
 (scheme, host, port) = (url.scheme(), url.host(), url.port())
 assert scheme
 if (not host):
  raise ValueError('Got URL {} without host.'.format(url.toDisplayString()))
 if (port == (-1)):
  port_mapping = {'http': 80, 'https': 443, 'ftp': 21}
  try:
   port = port_mapping[scheme]
  except KeyError:
   raise ValueError('Got URL {} with unknown port.'.format(url.toDisplayString()))
 return (scheme, host, port)

def host_tuple ( url ) : if ( not url . isValid ( ) ) : raise InvalidUrlError ( url ) ( scheme , host , port ) = ( url . scheme ( ) , url . host ( ) , url . port ( ) ) assert scheme if ( not host ) : raise ValueError ( 'Got URL {} without host.' . format ( url . toDisplayString ( ) ) ) if ( port == ( - 1 ) ) : port_mapping = { 'http' : 80 , 'https' : 443 , 'ftp' : 21 } try : port = port_mapping [ scheme ] except KeyError : raise ValueError ( 'Got URL {} with unknown port.' . format ( url . toDisplayString ( ) ) ) return ( scheme , host , port )
get a tuple from a qurl .