#NEWLINE# def sign_file( self , file_input , key = None , destination = None , key_id = None , passphrase = None , clearsign = False ) : #NEWLINE# #INDENT# '\n        Signs a filename, storing the signature and the original file\n        in the destination filename provided (the destination file is\n        overrided if it already exists), if no destination file name is\n        provided the signature is returned.\n        ' #NEWLINE# kwargs = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# kwargs [ 'clearsign' ] = clearsign #NEWLINE# if key_id : #NEWLINE# #INDENT# kwargs [ 'keyid' ] = key_id #NEWLINE# #UNINDENT# if key : #NEWLINE# #INDENT# kwargs [ 'keyid' ] = key . key_id #NEWLINE# #UNINDENT# if key : #NEWLINE# #INDENT# kwargs [ 'passphrase' ] = passphrase #NEWLINE# #UNINDENT# input_descriptor = GPG . get_descriptor ( file_input ) #NEWLINE# if destination : #NEWLINE# #INDENT# output_descriptor = open ( destination , 'wb' ) #NEWLINE# #UNINDENT# signed_data = self . gpg . sign_file ( input_descriptor , ** kwargs ) #NEWLINE# if ( not signed_data . fingerprint ) : #NEWLINE# #INDENT# raise GPGSigningError ( 'Unable to sign file' ) #NEWLINE# #UNINDENT# if destination : #NEWLINE# #INDENT# output_descriptor . write ( signed_data . data ) #NEWLINE# #UNINDENT# input_descriptor . close ( ) #NEWLINE# if destination : #NEWLINE# #INDENT# output_descriptor . close ( ) #NEWLINE# #UNINDENT# if ( not destination ) : #NEWLINE# #INDENT# return signed_data