def gzip_encode(data):
 if (not gzip):
  raise NotImplementedError
 f = BytesIO()
 gzf = gzip.GzipFile(mode='wb', fileobj=f, compresslevel=1)
 gzf.write(data)
 gzf.close()
 encoded = f.getvalue()
 f.close()
 return encoded

def gzip_encode ( data ) : if ( not gzip ) : raise NotImplementedError f = BytesIO ( ) gzf = gzip . GzipFile ( mode = 'wb' , fileobj = f , compresslevel = 1 ) gzf . write ( data ) gzf . close ( ) encoded = f . getvalue ( ) f . close ( ) return encoded
data -> gzip encoded data encode data using the gzip content encoding as described in rfc 1952 .