aboutsummaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorCosimo Lupo <cosimo.lupo@daltonmaag.com>2015-05-08 11:34:20 +0100
committerCosimo Lupo <cosimo.lupo@daltonmaag.com>2015-05-11 10:39:17 +0100
commitb2eba122c8b965129ae002791d868898affdccdc (patch)
treeaba7dd36fa9ccd2b0a70a9f93d039bda0403156b /python
parent89c74d68591e0938dce6ad9f7532cdd6490ed21c (diff)
downloadbrotli-b2eba122c8b965129ae002791d868898affdccdc.zip
brotli-b2eba122c8b965129ae002791d868898affdccdc.tar.gz
brotli-b2eba122c8b965129ae002791d868898affdccdc.tar.bz2
[brotlimodule] add enable_dictionary parameter (defautls to True)
Diffstat (limited to 'python')
-rw-r--r--python/brotlimodule.cc12
1 files changed, 9 insertions, 3 deletions
diff --git a/python/brotlimodule.cc b/python/brotlimodule.cc
index 2fc8125..515b701 100644
--- a/python/brotlimodule.cc
+++ b/python/brotlimodule.cc
@@ -36,8 +36,10 @@ PyDoc_STRVAR(compress__doc__,
" data (bytes): The input data.\n"
" mode (int, optional): The compression mode can be MODE_TEXT (default) or\n"
" MODE_FONT.\n"
+" enable_dictionary (bool, optional): Controls whether to enable encoder\n"
+" dictionary. Defaults to True. Respected only if quality > 9.\n"
" enable_transforms (bool, optional): Controls whether to enable encoder\n"
-" transforms. Defaults to False.\n"
+" transforms. Defaults to False. Respected only if quality > 9.\n"
"\n"
"Returns:\n"
" The compressed string of bytes.\n"
@@ -47,17 +49,19 @@ PyDoc_STRVAR(compress__doc__,
static PyObject* brotli_compress(PyObject *self, PyObject *args, PyObject *keywds) {
PyObject *ret = NULL;
+ PyObject* dictionary = NULL;
PyObject* transform = NULL;
uint8_t *input, *output;
size_t length, output_length;
BrotliParams::Mode mode = (BrotliParams::Mode) -1;
int ok;
- static char *kwlist[] = {"data", "mode", "enable_transforms", NULL};
+ static char *kwlist[] = {"data", "mode", "enable_dictionary", "enable_transforms", NULL};
- ok = PyArg_ParseTupleAndKeywords(args, keywds, "s#|O&O!:compress", kwlist,
+ ok = PyArg_ParseTupleAndKeywords(args, keywds, "s#|O&O!O!:compress", kwlist,
&input, &length,
&mode_convertor, &mode,
+ &PyBool_Type, &dictionary,
&PyBool_Type, &transform);
if (!ok)
@@ -69,6 +73,8 @@ static PyObject* brotli_compress(PyObject *self, PyObject *args, PyObject *keywd
BrotliParams params;
if (mode != -1)
params.mode = mode;
+ if (dictionary)
+ params.enable_dictionary = PyObject_IsTrue(dictionary);
if (transform)
params.enable_transforms = PyObject_IsTrue(transform);