#NEWLINE# def build_hmac_signature( self , http_request , oauth_params , consumer_secret , token_secret ) : #NEWLINE# #INDENT# raw = build_signature_base_string ( http_request , oauth_params ) #NEWLINE# key = None #NEWLINE# hashed = None #NEWLINE# if token_secret : #NEWLINE# #INDENT# key = ( '%s&%s' % ( escape ( token_secret ) , escape ( token_secret ) ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# key = ( '%s&' % escape ( consumer_secret ) ) #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# import hashlib #NEWLINE# hashed = hmac . new ( key , raw , hashlib . sha1 ) #NEWLINE# #UNINDENT# except ImportError : #NEWLINE# #INDENT# import sha #NEWLINE# hashed = hmac . new ( key , raw , sha ) #NEWLINE# #UNINDENT# return binascii . b2a_base64 ( hashed . digest ( ) ) [ : ( - 1 ) ]