#NEWLINE# def normalize( uristr ) : #NEWLINE# #INDENT# 'Translate the given URI into a normalized form.' #NEWLINE# uristr = uristr . encode ( 'utf-8' ) #NEWLINE# for scheme in URL_SCHEMES : #NEWLINE# #INDENT# if uristr . startswith ( ( ( VIA_PREFIX + scheme ) + ':' ) ) : #NEWLINE# #INDENT# uristr = uristr [ len ( VIA_PREFIX ) : ] #NEWLINE# break #NEWLINE# #UNINDENT# #UNINDENT# uri = urlparse . urlsplit ( uristr ) #NEWLINE# if ( uri . scheme . lower ( ) not in URL_SCHEMES ) : #NEWLINE# #INDENT# return text_type ( uristr , 'utf-8' ) #NEWLINE# #UNINDENT# if ( uri . hostname is None ) : #NEWLINE# #INDENT# return text_type ( uristr , 'utf-8' ) #NEWLINE# #UNINDENT# scheme = uri . scheme #NEWLINE# netloc = _normalize_netloc ( uri ) #NEWLINE# path = _normalize_path ( uri ) #NEWLINE# query = _normalize_query ( uri ) #NEWLINE# fragment = None #NEWLINE# uri = urlparse . SplitResult ( scheme , netloc , path , query , fragment ) #NEWLINE# return text_type ( uri . geturl ( ) , 'utf-8' )