Skip to content

Commit

Permalink
[brotlimodule] add MODE_GENERIC constant
Browse files Browse the repository at this point in the history
  • Loading branch information
Cosimo Lupo committed May 11, 2015
1 parent b7e8291 commit aa6f7d8
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions python/brotlimodule.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ static int mode_convertor(PyObject *o, BrotliParams::Mode *mode) {
}

*mode = (BrotliParams::Mode) PyInt_AsLong(o);
if (*mode != BrotliParams::Mode::MODE_TEXT &&
if (*mode != BrotliParams::Mode::MODE_GENERIC &&
*mode != BrotliParams::Mode::MODE_TEXT &&
*mode != BrotliParams::Mode::MODE_FONT) {
PyErr_SetString(BrotliError, "Invalid mode");
return 0;
Expand Down Expand Up @@ -78,14 +79,14 @@ PyDoc_STRVAR(compress__doc__,
"Compress a byte string.\n"
"\n"
"Signature:\n"
" compress(string, mode=MODE_TEXT, quality=11, lgwin=22, lgblock=0,\n"
" compress(string, mode=MODE_GENERIC, quality=11, lgwin=22, lgblock=0,\n"
" enable_dictionary=True, enable_transforms=False\n"
" greedy_block_split=False, enable_context_modeling=True)\n"
"\n"
"Args:\n"
" string (bytes): The input data.\n"
" mode (int, optional): The compression mode can be MODE_TEXT (default) or\n"
" MODE_FONT.\n"
" mode (int, optional): The compression mode can be MODE_GENERIC (default),\n"
" MODE_TEXT (for UTF-8 format text input) or MODE_FONT (for WOFF 2.0). \n"
" quality (int, optional): Controls the compression-speed vs compression-\n"
" density tradeoff. The higher the quality, the slower the compression.\n"
" Range is 0 to 11. Defaults to 11.\n"
Expand Down Expand Up @@ -265,6 +266,7 @@ PyMODINIT_FUNC INIT_BROTLI(void) {
PyModule_AddObject(m, "error", BrotliError);
}

PyModule_AddIntConstant(m, "MODE_GENERIC", (int) BrotliParams::Mode::MODE_GENERIC);
PyModule_AddIntConstant(m, "MODE_TEXT", (int) BrotliParams::Mode::MODE_TEXT);
PyModule_AddIntConstant(m, "MODE_FONT", (int) BrotliParams::Mode::MODE_FONT);

Expand Down

0 comments on commit aa6f7d8

Please sign in to comment.