#NEWLINE# def add_auth( self , host , headers ) : #NEWLINE# #INDENT# '\n        Add Basic authentication information to the headers if it is given\n        in host.\n        ' #NEWLINE# url = ( 'http://%s' % host ) #NEWLINE# parsed = urlparse . urlparse ( url ) #NEWLINE# if ( parsed . username and parsed . password ) : #NEWLINE# #INDENT# auth = ( '%s:%s' % ( parsed . username , parsed . password ) ) #NEWLINE# headers [ 'HTTP_AUTHORIZATION' ] = ( 'Basic %s' % base64 . b64encode ( auth ) )