diff options
Diffstat (limited to 'python')
-rw-r--r-- | python/_brotli.cc (renamed from python/brotlimodule.cc) | 14 | ||||
-rw-r--r-- | python/brotli.py | 26 |
2 files changed, 32 insertions, 8 deletions
diff --git a/python/brotlimodule.cc b/python/_brotli.cc index 1d3b208..27e8346 100644 --- a/python/brotlimodule.cc +++ b/python/_brotli.cc @@ -244,7 +244,7 @@ static PyObject* brotli_decompress(PyObject *self, PyObject *args, PyObject *key } else { PyErr_SetString(BrotliError, "BrotliDecompress failed"); } - + BrotliDecoderDestroyInstance(state); delete[] buffer; @@ -257,18 +257,16 @@ static PyMethodDef brotli_methods[] = { {NULL, NULL, 0, NULL} }; -PyDoc_STRVAR(brotli__doc__, -"The functions in this module allow compression and decompression using the\n" -"Brotli library.\n\n"); +PyDoc_STRVAR(brotli__doc__, "Implementation module for the Brotli library."); #if PY_MAJOR_VERSION >= 3 -#define INIT_BROTLI PyInit_brotli +#define INIT_BROTLI PyInit__brotli #define CREATE_BROTLI PyModule_Create(&brotli_module) #define RETURN_BROTLI return m static struct PyModuleDef brotli_module = { PyModuleDef_HEAD_INIT, - "brotli", + "_brotli", brotli__doc__, 0, brotli_methods, @@ -277,8 +275,8 @@ static struct PyModuleDef brotli_module = { NULL }; #else -#define INIT_BROTLI initbrotli -#define CREATE_BROTLI Py_InitModule3("brotli", brotli_methods, brotli__doc__) +#define INIT_BROTLI init_brotli +#define CREATE_BROTLI Py_InitModule3("_brotli", brotli_methods, brotli__doc__) #define RETURN_BROTLI return #endif diff --git a/python/brotli.py b/python/brotli.py new file mode 100644 index 0000000..b63e218 --- /dev/null +++ b/python/brotli.py @@ -0,0 +1,26 @@ +# Copyright 2016 The Brotli Authors. All rights reserved. +# +# Distributed under MIT license. +# See file LICENSE for detail or copy at https://opensource.org/licenses/MIT + +"""Functions to compress and decompress data using the Brotli library.""" + +import _brotli + + +# The library version. +__version__ = _brotli.__version__ + +# The compression mode. +MODE_GENERIC = _brotli.MODE_GENERIC +MODE_TEXT = _brotli.MODE_TEXT +MODE_FONT = _brotli.MODE_FONT + +# Compress a byte string. +compress = _brotli.compress + +# Decompress a compressed byte string. +decompress = _brotli.decompress + +# Raised if compression or decompression fails. +error = _brotli.error |