def to_host_port_tuple(host_port_str, default_port=80):
 uri = URIReference(scheme=None, authority=host_port_str, path=None, query=None, fragment=None)
 host = uri.host.strip('[]')
 if (not uri.port):
  port = default_port
 else:
  port = int(uri.port)
 return (host, port)

def to_host_port_tuple ( host_port_str , default_port = 80 ) : uri = URIReference ( scheme = None , authority = host_port_str , path = None , query = None , fragment = None ) host = uri . host . strip ( '[]' ) if ( not uri . port ) : port = default_port else : port = int ( uri . port ) return ( host , port )
converts the given string containing a host and possibly a port to a tuple .