class bz2.BZ2Compressor(compresslevel=9)
Create a new compressor object. This object may be used to compress data incrementally. For one-shot compression, use the compress() function instead.
compresslevel, if given, must be a number between 1 and 9. The default is 9.
compress(data)
Provide data to the compressor object. Returns a chunk of compressed data if possible, or an empty byte string otherwise. When you have finished providing data to the compressor, call the flush() method to fin