aboutsummaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorCosimo Lupo <cosimo.lupo@daltonmaag.com>2015-05-08 11:23:08 +0100
committerCosimo Lupo <cosimo.lupo@daltonmaag.com>2015-05-11 10:39:15 +0100
commit89c74d68591e0938dce6ad9f7532cdd6490ed21c (patch)
tree117172a15fb397e0c6f28dbafbe586a6692a4381 /python
parent621cd0cf04c507492164c0eecb7481bfa898c43f (diff)
downloadbrotli-89c74d68591e0938dce6ad9f7532cdd6490ed21c.zip
brotli-89c74d68591e0938dce6ad9f7532cdd6490ed21c.tar.gz
brotli-89c74d68591e0938dce6ad9f7532cdd6490ed21c.tar.bz2
[brotlimodule] use keyword arguments for mode and enable_transforms;
update brotli.compress docstring accordingly
Diffstat (limited to 'python')
-rw-r--r--python/brotlimodule.cc25
1 files changed, 18 insertions, 7 deletions
diff --git a/python/brotlimodule.cc b/python/brotlimodule.cc
index 2ae97d1..2fc8125 100644
--- a/python/brotlimodule.cc
+++ b/python/brotlimodule.cc
@@ -30,13 +30,22 @@ static int mode_convertor(PyObject *o, BrotliParams::Mode *mode) {
}
PyDoc_STRVAR(compress__doc__,
-"compress(string[, mode[, transform]]) -- Returned compressed string.\n"
+"compress(data[, mode=MODE_TEXT, enable_transforms=False])\n"
"\n"
-"Optional arg mode is the compression mode, either MODE_TEXT (default) or\n"
-"MODE_FONT. Optional boolean arg transform controls whether to enable\n"
-"encoder transforms or not, defaults to False.");
+"Args:\n"
+" data (bytes): The input data.\n"
+" mode (int, optional): The compression mode can be MODE_TEXT (default) or\n"
+" MODE_FONT.\n"
+" enable_transforms (bool, optional): Controls whether to enable encoder\n"
+" transforms. Defaults to False.\n"
+"\n"
+"Returns:\n"
+" The compressed string of bytes.\n"
+"\n"
+"Raises:\n"
+" brotli.error: If mode is invalid, or compressor fails.\n");
-static PyObject* brotli_compress(PyObject *self, PyObject *args) {
+static PyObject* brotli_compress(PyObject *self, PyObject *args, PyObject *keywds) {
PyObject *ret = NULL;
PyObject* transform = NULL;
uint8_t *input, *output;
@@ -44,7 +53,9 @@ static PyObject* brotli_compress(PyObject *self, PyObject *args) {
BrotliParams::Mode mode = (BrotliParams::Mode) -1;
int ok;
- ok = PyArg_ParseTuple(args, "s#|O&O!:compress",
+ static char *kwlist[] = {"data", "mode", "enable_transforms", NULL};
+
+ ok = PyArg_ParseTupleAndKeywords(args, keywds, "s#|O&O!:compress", kwlist,
&input, &length,
&mode_convertor, &mode,
&PyBool_Type, &transform);
@@ -112,7 +123,7 @@ static PyObject* brotli_decompress(PyObject *self, PyObject *args) {
}
static PyMethodDef brotli_methods[] = {
- {"compress", brotli_compress, METH_VARARGS, compress__doc__},
+ {"compress", (PyCFunction)brotli_compress, METH_VARARGS | METH_KEYWORDS, compress__doc__},
{"decompress", brotli_decompress, METH_VARARGS, decompress__doc__},
{NULL, NULL, 0, NULL}
};