#NEWLINE# @ classmethod #NEWLINE# def from_url( cls , url , show_host = True ) : #NEWLINE# #INDENT# 'Parse string and get URL instance' #NEWLINE# url = urlparse ( url ) #NEWLINE# query = sum ( [ [ ( k . decode ( 'utf-8' , errors = 'replace' ) , v . decode ( 'utf-8' , errors = 'replace' ) ) for v in values ] for ( k , values ) in parse_qs ( url . query ) . items ( ) ] , [ ] ) #NEWLINE# host = ( url . netloc . split ( ':' , 1 ) [ 0 ] if ( ':' in url . netloc ) else url . netloc ) #NEWLINE# if isinstance ( host , unicode ) : #NEWLINE# #INDENT# host = host . encode ( 'idna' ) #NEWLINE# #UNINDENT# port = ( url . netloc . split ( ':' ) [ 1 ] if ( ':' in url . netloc ) else '' ) #NEWLINE# path = urllib . unquote ( url . path ) #NEWLINE# if isinstance ( url . path , str ) : #NEWLINE# #INDENT# path = path . decode ( 'utf-8' ) #NEWLINE# #UNINDENT# return cls ( path , query , host . decode ( 'idna' ) , port , url . scheme , show_host )