def _write_fileobject(filename, compress=('zlib', 3)):
 compressmethod = compress[0]
 compresslevel = compress[1]
 if (compressmethod == 'gzip'):
  return _buffered_write_file(BinaryGzipFile(filename, 'wb', compresslevel=compresslevel))
 elif (compressmethod == 'bz2'):
  return _buffered_write_file(bz2.BZ2File(filename, 'wb', compresslevel=compresslevel))
 elif ((lzma is not None) and (compressmethod == 'xz')):
  return _buffered_write_file(lzma.LZMAFile(filename, 'wb', check=lzma.CHECK_NONE, preset=compresslevel))
 elif ((lzma is not None) and (compressmethod == 'lzma')):
  return _buffered_write_file(lzma.LZMAFile(filename, 'wb', preset=compresslevel, format=lzma.FORMAT_ALONE))
 else:
  return _buffered_write_file(BinaryZlibFile(filename, 'wb', compresslevel=compresslevel))

def _write_fileobject ( filename , compress = ( 'zlib' , 3 ) ) : compressmethod = compress [ 0 ] compresslevel = compress [ 1 ] if ( compressmethod == 'gzip' ) : return _buffered_write_file ( BinaryGzipFile ( filename , 'wb' , compresslevel = compresslevel ) ) elif ( compressmethod == 'bz2' ) : return _buffered_write_file ( bz2 . BZ2File ( filename , 'wb' , compresslevel = compresslevel ) ) elif ( ( lzma is not None ) and ( compressmethod == 'xz' ) ) : return _buffered_write_file ( lzma . LZMAFile ( filename , 'wb' , check = lzma . CHECK_NONE , preset = compresslevel ) ) elif ( ( lzma is not None ) and ( compressmethod == 'lzma' ) ) : return _buffered_write_file ( lzma . LZMAFile ( filename , 'wb' , preset = compresslevel , format = lzma . FORMAT_ALONE ) ) else : return _buffered_write_file ( BinaryZlibFile ( filename , 'wb' , compresslevel = compresslevel ) )
return the right compressor file object in write mode .