Serhiy Storchaka | 1bc4bb2 | 2014-01-25 12:07:57 +0200 | [diff] [blame] | 1 | /*[clinic input] |
| 2 | preserve |
| 3 | [clinic start generated code]*/ |
| 4 | |
| 5 | PyDoc_STRVAR(_bz2_BZ2Compressor_compress__doc__, |
Larry Hastings | 2623c8c | 2014-02-08 22:15:29 -0800 | [diff] [blame] | 6 | "compress($self, data, /)\n" |
| 7 | "--\n" |
| 8 | "\n" |
Serhiy Storchaka | 1bc4bb2 | 2014-01-25 12:07:57 +0200 | [diff] [blame] | 9 | "Provide data to the compressor object.\n" |
| 10 | "\n" |
| 11 | "Returns a chunk of compressed data if possible, or b\'\' otherwise.\n" |
| 12 | "\n" |
| 13 | "When you have finished providing data to the compressor, call the\n" |
| 14 | "flush() method to finish the compression process."); |
| 15 | |
| 16 | #define _BZ2_BZ2COMPRESSOR_COMPRESS_METHODDEF \ |
| 17 | {"compress", (PyCFunction)_bz2_BZ2Compressor_compress, METH_VARARGS, _bz2_BZ2Compressor_compress__doc__}, |
| 18 | |
| 19 | static PyObject * |
| 20 | _bz2_BZ2Compressor_compress_impl(BZ2Compressor *self, Py_buffer *data); |
| 21 | |
| 22 | static PyObject * |
| 23 | _bz2_BZ2Compressor_compress(BZ2Compressor *self, PyObject *args) |
| 24 | { |
| 25 | PyObject *return_value = NULL; |
| 26 | Py_buffer data = {NULL, NULL}; |
| 27 | |
| 28 | if (!PyArg_ParseTuple(args, |
| 29 | "y*:compress", |
| 30 | &data)) |
| 31 | goto exit; |
| 32 | return_value = _bz2_BZ2Compressor_compress_impl(self, &data); |
| 33 | |
| 34 | exit: |
| 35 | /* Cleanup for data */ |
| 36 | if (data.obj) |
| 37 | PyBuffer_Release(&data); |
| 38 | |
| 39 | return return_value; |
| 40 | } |
| 41 | |
| 42 | PyDoc_STRVAR(_bz2_BZ2Compressor_flush__doc__, |
Larry Hastings | 2623c8c | 2014-02-08 22:15:29 -0800 | [diff] [blame] | 43 | "flush($self, /)\n" |
| 44 | "--\n" |
| 45 | "\n" |
Serhiy Storchaka | 1bc4bb2 | 2014-01-25 12:07:57 +0200 | [diff] [blame] | 46 | "Finish the compression process.\n" |
| 47 | "\n" |
| 48 | "Returns the compressed data left in internal buffers.\n" |
| 49 | "\n" |
| 50 | "The compressor object may not be used after this method is called."); |
| 51 | |
| 52 | #define _BZ2_BZ2COMPRESSOR_FLUSH_METHODDEF \ |
| 53 | {"flush", (PyCFunction)_bz2_BZ2Compressor_flush, METH_NOARGS, _bz2_BZ2Compressor_flush__doc__}, |
| 54 | |
| 55 | static PyObject * |
| 56 | _bz2_BZ2Compressor_flush_impl(BZ2Compressor *self); |
| 57 | |
| 58 | static PyObject * |
| 59 | _bz2_BZ2Compressor_flush(BZ2Compressor *self, PyObject *Py_UNUSED(ignored)) |
| 60 | { |
| 61 | return _bz2_BZ2Compressor_flush_impl(self); |
| 62 | } |
| 63 | |
| 64 | PyDoc_STRVAR(_bz2_BZ2Compressor___init____doc__, |
Larry Hastings | 2623c8c | 2014-02-08 22:15:29 -0800 | [diff] [blame] | 65 | "BZ2Compressor(compresslevel=9, /)\n" |
| 66 | "--\n" |
| 67 | "\n" |
Serhiy Storchaka | 1bc4bb2 | 2014-01-25 12:07:57 +0200 | [diff] [blame] | 68 | "Create a compressor object for compressing data incrementally.\n" |
| 69 | "\n" |
| 70 | " compresslevel\n" |
| 71 | " Compression level, as a number between 1 and 9.\n" |
| 72 | "\n" |
| 73 | "For one-shot compression, use the compress() function instead."); |
| 74 | |
| 75 | static int |
| 76 | _bz2_BZ2Compressor___init___impl(BZ2Compressor *self, int compresslevel); |
| 77 | |
| 78 | static int |
| 79 | _bz2_BZ2Compressor___init__(PyObject *self, PyObject *args, PyObject *kwargs) |
| 80 | { |
| 81 | int return_value = -1; |
| 82 | int compresslevel = 9; |
| 83 | |
Larry Hastings | f0537e8 | 2014-01-25 22:01:12 -0800 | [diff] [blame] | 84 | if ((Py_TYPE(self) == &BZ2Compressor_Type) && |
| 85 | !_PyArg_NoKeywords("BZ2Compressor", kwargs)) |
Serhiy Storchaka | 1bc4bb2 | 2014-01-25 12:07:57 +0200 | [diff] [blame] | 86 | goto exit; |
| 87 | if (!PyArg_ParseTuple(args, |
| 88 | "|i:BZ2Compressor", |
| 89 | &compresslevel)) |
| 90 | goto exit; |
| 91 | return_value = _bz2_BZ2Compressor___init___impl((BZ2Compressor *)self, compresslevel); |
| 92 | |
| 93 | exit: |
| 94 | return return_value; |
| 95 | } |
| 96 | |
| 97 | PyDoc_STRVAR(_bz2_BZ2Decompressor_decompress__doc__, |
Larry Hastings | 2623c8c | 2014-02-08 22:15:29 -0800 | [diff] [blame] | 98 | "decompress($self, data, /)\n" |
| 99 | "--\n" |
| 100 | "\n" |
Serhiy Storchaka | 1bc4bb2 | 2014-01-25 12:07:57 +0200 | [diff] [blame] | 101 | "Provide data to the decompressor object.\n" |
| 102 | "\n" |
| 103 | "Returns a chunk of decompressed data if possible, or b\'\' otherwise.\n" |
| 104 | "\n" |
| 105 | "Attempting to decompress data after the end of stream is reached\n" |
| 106 | "raises an EOFError. Any data found after the end of the stream\n" |
| 107 | "is ignored and saved in the unused_data attribute."); |
| 108 | |
| 109 | #define _BZ2_BZ2DECOMPRESSOR_DECOMPRESS_METHODDEF \ |
| 110 | {"decompress", (PyCFunction)_bz2_BZ2Decompressor_decompress, METH_VARARGS, _bz2_BZ2Decompressor_decompress__doc__}, |
| 111 | |
| 112 | static PyObject * |
| 113 | _bz2_BZ2Decompressor_decompress_impl(BZ2Decompressor *self, Py_buffer *data); |
| 114 | |
| 115 | static PyObject * |
| 116 | _bz2_BZ2Decompressor_decompress(BZ2Decompressor *self, PyObject *args) |
| 117 | { |
| 118 | PyObject *return_value = NULL; |
| 119 | Py_buffer data = {NULL, NULL}; |
| 120 | |
| 121 | if (!PyArg_ParseTuple(args, |
| 122 | "y*:decompress", |
| 123 | &data)) |
| 124 | goto exit; |
| 125 | return_value = _bz2_BZ2Decompressor_decompress_impl(self, &data); |
| 126 | |
| 127 | exit: |
| 128 | /* Cleanup for data */ |
| 129 | if (data.obj) |
| 130 | PyBuffer_Release(&data); |
| 131 | |
| 132 | return return_value; |
| 133 | } |
| 134 | |
| 135 | PyDoc_STRVAR(_bz2_BZ2Decompressor___init____doc__, |
Larry Hastings | 2623c8c | 2014-02-08 22:15:29 -0800 | [diff] [blame] | 136 | "BZ2Decompressor()\n" |
| 137 | "--\n" |
| 138 | "\n" |
Serhiy Storchaka | 1bc4bb2 | 2014-01-25 12:07:57 +0200 | [diff] [blame] | 139 | "Create a decompressor object for decompressing data incrementally.\n" |
| 140 | "\n" |
| 141 | "For one-shot decompression, use the decompress() function instead."); |
| 142 | |
| 143 | static int |
| 144 | _bz2_BZ2Decompressor___init___impl(BZ2Decompressor *self); |
| 145 | |
| 146 | static int |
| 147 | _bz2_BZ2Decompressor___init__(PyObject *self, PyObject *args, PyObject *kwargs) |
| 148 | { |
| 149 | int return_value = -1; |
| 150 | |
Larry Hastings | f0537e8 | 2014-01-25 22:01:12 -0800 | [diff] [blame] | 151 | if ((Py_TYPE(self) == &BZ2Decompressor_Type) && |
| 152 | !_PyArg_NoPositional("BZ2Decompressor", args)) |
Serhiy Storchaka | 1bc4bb2 | 2014-01-25 12:07:57 +0200 | [diff] [blame] | 153 | goto exit; |
Larry Hastings | f0537e8 | 2014-01-25 22:01:12 -0800 | [diff] [blame] | 154 | if ((Py_TYPE(self) == &BZ2Decompressor_Type) && |
| 155 | !_PyArg_NoKeywords("BZ2Decompressor", kwargs)) |
Serhiy Storchaka | 1bc4bb2 | 2014-01-25 12:07:57 +0200 | [diff] [blame] | 156 | goto exit; |
| 157 | return_value = _bz2_BZ2Decompressor___init___impl((BZ2Decompressor *)self); |
| 158 | |
| 159 | exit: |
| 160 | return return_value; |
| 161 | } |
Larry Hastings | 2623c8c | 2014-02-08 22:15:29 -0800 | [diff] [blame] | 162 | /*[clinic end generated code: output=21ca4405519a0931 input=a9049054013a1b77]*/ |