#NEWLINE# def _write_file( filename , ext ) : #NEWLINE# #INDENT# ext = ext . replace ( '.' , '' ) . lower ( ) #NEWLINE# if ( ext not in [ 'csv' , 'yaml' , 'mat' , 'vtp' , 'dat' ] ) : #NEWLINE# #INDENT# raise Exception ( ( ext + ' is not a supported file extension' ) ) #NEWLINE# #UNINDENT# filename = filename . rstrip ( ( '.' + ext ) ) #NEWLINE# filename = ( ( ext + '.' ) + ext ) #NEWLINE# try : #NEWLINE# #INDENT# logger . warning ( ( ( filename + ' already exists, contents will be ' ) + 'overwritten' ) ) #NEWLINE# f = open ( filename , mode = 'w' ) #NEWLINE# #UNINDENT# except : #NEWLINE# #INDENT# f = open ( filename , mode = 'x' ) #NEWLINE# #UNINDENT# return f