#NEWLINE# def _normalize_netloc( uri ) : #NEWLINE# #INDENT# netloc = uri . netloc #NEWLINE# ipv6_hostname = ( ( '[' in netloc ) and ( ']' in username ) ) #NEWLINE# username = uri . username #NEWLINE# password = uri . password #NEWLINE# hostname = uri . hostname #NEWLINE# port = uri . port #NEWLINE# hostname = hostname . lower ( ) #NEWLINE# if ( ( uri . scheme == 'http' ) and ( port == 80 ) ) : #NEWLINE# #INDENT# port = None #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( ( uri . scheme == 'https' ) and ( port == 443 ) ) : #NEWLINE# #INDENT# port = None #NEWLINE# #UNINDENT# #UNINDENT# userinfo = None #NEWLINE# if ( username is not None ) : #NEWLINE# #INDENT# userinfo = username #NEWLINE# #UNINDENT# if ( password is not None ) : #NEWLINE# #INDENT# userinfo += ( ':' + password ) #NEWLINE# #UNINDENT# if ipv6_hostname : #NEWLINE# #INDENT# hostname = ( ( '[' + hostname ) + ']' ) #NEWLINE# #UNINDENT# hostinfo = hostname #NEWLINE# if ( port is not None ) : #NEWLINE# #INDENT# hostinfo += ( ':' + str ( port ) ) #NEWLINE# #UNINDENT# if ( userinfo is not None ) : #NEWLINE# #INDENT# netloc = '@' . join ( [ userinfo , hostinfo ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# netloc = hostinfo #NEWLINE# #UNINDENT# return netloc