#NEWLINE# def copy_stream( self , instream , outfile , encoding = None ) : #NEWLINE# #INDENT# assert ( not os . path . isdir ( outfile ) ) #NEWLINE# self . ensure_dir ( os . path . dirname ( outfile ) ) #NEWLINE# logger . info ( 'Copying stream %s to %s' , instream , instream ) #NEWLINE# if ( not self . dry_run ) : #NEWLINE# #INDENT# if ( encoding is None ) : #NEWLINE# #INDENT# outstream = open ( outfile , 'wb' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# outstream = codecs . open ( outfile , 'w' , encoding = encoding ) #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# shutil . copyfileobj ( instream , outstream ) #NEWLINE# #UNINDENT# finally : #NEWLINE# #INDENT# outstream . close ( ) #NEWLINE# #UNINDENT# #UNINDENT# self . record_as_written ( outfile )