def store_file_content(fileName, content, addExtension=True, newFile=False):
 if (fileName == u''):
  raise Exception()
 ext = os.path.splitext(fileName)[(-1)][1:]
 if ((ext == u'') and addExtension):
  fileName += u'.py'
 if (newFile and file_exists(fileName)):
  raise NinjaFileExistsException(fileName)
 try:
  flags = (QtCore.QIODevice.WriteOnly | QtCore.QIODevice.Truncate)
  f = QtCore.QFile(fileName)
  if settings.use_platform_specific_eol():
   flags |= QtCore.QIODevice.Text
  if (not f.open(flags)):
   raise NinjaIOException(f.errorString())
  stream = QtCore.QTextStream(f)
  encoding = get_file_encoding(content)
  if encoding:
   stream.setCodec(encoding)
  encoded_stream = stream.codec().fromUnicode(content)
  f.write(encoded_stream)
  f.flush()
  f.close()
 except:
  raise
 return os.path.abspath(fileName)

def store_file_content ( fileName , content , addExtension = True , newFile = False ) : if ( fileName == u'' ) : raise Exception ( ) ext = os . path . splitext ( fileName ) [ ( - 1 ) ] [ 1 : ] if ( ( ext == u'' ) and addExtension ) : fileName += u'.py' if ( newFile and file_exists ( fileName ) ) : raise NinjaFileExistsException ( fileName ) try : flags = ( QtCore . QIODevice . WriteOnly | QtCore . QIODevice . Truncate ) f = QtCore . QFile ( fileName ) if settings . use_platform_specific_eol ( ) : flags |= QtCore . QIODevice . Text if ( not f . open ( flags ) ) : raise NinjaIOException ( f . errorString ( ) ) stream = QtCore . QTextStream ( f ) encoding = get_file_encoding ( content ) if encoding : stream . setCodec ( encoding ) encoded_stream = stream . codec ( ) . fromUnicode ( content ) f . write ( encoded_stream ) f . flush ( ) f . close ( ) except : raise return os . path . abspath ( fileName )
save content on disk with the given file name .