#NEWLINE# def writefile( dest , content , overwrite = True ) : #NEWLINE# #INDENT# if ( not os . path . exists ( dest ) ) : #NEWLINE# #INDENT# logger . info ( 'Writing %s' , dest ) #NEWLINE# f = open ( f , 'wb' ) #NEWLINE# f . write ( content . encode ( 'utf-8' ) ) #NEWLINE# f . close ( ) #NEWLINE# return #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# f = open ( dest , 'rb' ) #NEWLINE# c = f . read ( ) #NEWLINE# f . close ( ) #NEWLINE# if ( c != content . encode ( 'utf-8' ) ) : #NEWLINE# #INDENT# if ( not overwrite ) : #NEWLINE# #INDENT# logger . notify ( 'File %s exists with different content; not overwriting' , dest ) #NEWLINE# return #NEWLINE# #UNINDENT# logger . notify ( 'Overwriting %s with new content' , dest ) #NEWLINE# f = open ( dest , 'wb' ) #NEWLINE# f . write ( content . encode ( 'utf-8' ) ) #NEWLINE# f . close ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# logger . info ( 'Content %s already in place' , dest )