Python: Publicly expose the Compressor object in the Python API (#456)

Progress on #191
This commit is contained in:
Alex Nicksay 2016-10-25 04:19:29 -04:00 committed by Eugene Kliuchnikov
parent 5632315d35
commit afb1272792

View File

@ -16,6 +16,9 @@ MODE_GENERIC = _brotli.MODE_GENERIC
MODE_TEXT = _brotli.MODE_TEXT MODE_TEXT = _brotli.MODE_TEXT
MODE_FONT = _brotli.MODE_FONT MODE_FONT = _brotli.MODE_FONT
# The Compressor object.
Compressor = _brotli.Compressor
# Compress a byte string. # Compress a byte string.
def compress(string, mode=MODE_GENERIC, quality=11, lgwin=22, lgblock=0, def compress(string, mode=MODE_GENERIC, quality=11, lgwin=22, lgblock=0,
dictionary=''): dictionary=''):
@ -42,7 +45,7 @@ def compress(string, mode=MODE_GENERIC, quality=11, lgwin=22, lgblock=0,
Raises: Raises:
brotli.error: If arguments are invalid, or compressor fails. brotli.error: If arguments are invalid, or compressor fails.
""" """
compressor = _brotli.Compressor(mode=mode, quality=quality, lgwin=lgwin, compressor = Compressor(mode=mode, quality=quality, lgwin=lgwin,
lgblock=lgblock, dictionary=dictionary) lgblock=lgblock, dictionary=dictionary)
return compressor.process(string) + compressor.finish() return compressor.process(string) + compressor.finish()