Doc strings (AMK).

This commit is contained in:
Guido van Rossum 1997-06-03 22:21:03 +00:00
parent 2b1566be9d
commit 3c540307af
1 changed files with 88 additions and 11 deletions

View File

@ -27,6 +27,16 @@ typedef struct
z_stream zst;
} compobject;
static char compressobj__doc__[] =
"compressobj() -- Return a compressor object.\n"
"compressobj(level) -- Return a compressor object, using the given compression level.\n"
;
static char decompressobj__doc__[] =
"decompressobj() -- Return a decompressor object.\n"
"decompressobj(wbits) -- Return a decompressor object, setting the window buffer size to wbits.\n"
;
static compobject *
newcompobject(type)
PyTypeObject *type;
@ -38,6 +48,13 @@ newcompobject(type)
return self;
}
static char compress__doc__[] =
"compress(string) -- Compress string using the default compression level, "
"returning a string containing compressed data.\n"
"compress(string, level) -- Compress string, using the chosen compression "
"level (from 1 to 9). Return a string containing the compressed data.\n"
;
static PyObject *
PyZlib_compress(self, args)
PyObject *self;
@ -125,6 +142,11 @@ PyZlib_compress(self, args)
return ReturnVal;
}
static char decompress__doc__[] =
"decompress(string) -- Decompress the data in string, returning "
"a string containing the decompressed data."
;
static PyObject *
PyZlib_decompress(self, args)
PyObject *self;
@ -341,6 +363,14 @@ Decomp_dealloc(self)
err=inflateEnd(&self->zst); /* Deallocate zstream structure */
}
static char comp_compress__doc__[] =
"compress(data) -- Return a string containing a compressed version of the data.\n\n"
"After calling this function, some of the input data may still\n"
"be stored in internal buffers for later processing.\n"
"Call the flush() method to clear these buffers."
;
static PyObject *
PyZlib_objcompress(self, args)
compobject *self;
@ -383,6 +413,13 @@ PyZlib_objcompress(self, args)
return RetVal;
}
static char decomp_decompress__doc__[] =
"decompress(data) -- Return a string containing the decompressed version of the data.\n\n"
"After calling this function, some of the input data may still\n"
"be stored in internal buffers for later processing.\n"
"Call the flush() method to clear these buffers."
;
static PyObject *
PyZlib_objdecompress(self, args)
compobject *self;
@ -424,6 +461,11 @@ PyZlib_objdecompress(self, args)
return RetVal;
}
static char comp_flush__doc__[] =
"flush() -- Return a string containing any remaining compressed data. "
"The compressor object can no longer be used after this call."
;
static PyObject *
PyZlib_flush(self, args)
compobject *self;
@ -474,6 +516,11 @@ PyZlib_flush(self, args)
return RetVal;
}
static char decomp_flush__doc__[] =
"flush() -- Return a string containing any remaining decompressed data. "
"The decompressor object can no longer be used after this call."
;
static PyObject *
PyZlib_unflush(self, args)
compobject *self;
@ -525,15 +572,15 @@ PyZlib_unflush(self, args)
static PyMethodDef comp_methods[] =
{
{"compress", PyZlib_objcompress, 1},
{"flush", PyZlib_flush, 0},
{"compress", PyZlib_objcompress, 1, comp_compress__doc__},
{"flush", PyZlib_flush, 0, comp_flush__doc__},
{NULL, NULL}
};
static PyMethodDef Decomp_methods[] =
{
{"decompress", PyZlib_objdecompress, 1},
{"flush", PyZlib_unflush, 0},
{"decompress", PyZlib_objdecompress, 1, decomp_decompress__doc__},
{"flush", PyZlib_unflush, 0, decomp_flush__doc__},
{NULL, NULL}
};
@ -553,6 +600,13 @@ Decomp_getattr(self, name)
return Py_FindMethod(Decomp_methods, (PyObject *)self, name);
}
static char adler32__doc__[] =
"adler32(string) -- Compute an Adler-32 checksum of string, using "
"a default starting value, and returning an integer value.\n"
"adler32(string, value) -- Compute an Adler-32 checksum of string, using "
"the starting value provided, and returning an integer value\n"
;
static PyObject *
PyZlib_adler32(self, args)
PyObject *self, *args;
@ -569,6 +623,12 @@ PyZlib_adler32(self, args)
return Py_BuildValue("l", adler32val);
}
static char crc32__doc__[] =
"crc32(string) -- Compute a CRC-32 checksum of string, using "
"a default starting value, and returning an integer value.\n"
"crc32(string, value) -- Compute a CRC-32 checksum of string, using "
"the starting value provided, and returning an integer value.\n"
;
static PyObject *
PyZlib_crc32(self, args)
@ -588,12 +648,12 @@ PyZlib_crc32(self, args)
static PyMethodDef zlib_methods[] =
{
{"adler32", PyZlib_adler32, 1},
{"compress", PyZlib_compress, 1},
{"compressobj", PyZlib_compressobj, 1},
{"crc32", PyZlib_crc32, 1},
{"decompress", PyZlib_decompress, 1},
{"decompressobj", PyZlib_decompressobj, 1},
{"adler32", (PyCFunction)PyZlib_adler32, 1, adler32__doc__},
{"compress", (PyCFunction)PyZlib_compress, 1, compress__doc__},
{"compressobj", (PyCFunction)PyZlib_compressobj, 1, compressobj__doc__},
{"crc32", (PyCFunction)PyZlib_crc32, 1, crc32__doc__},
{"decompress", (PyCFunction)PyZlib_decompress, 1, decompress__doc__},
{"decompressobj", (PyCFunction)PyZlib_decompressobj, 1, decompressobj__doc__},
{NULL, NULL}
};
@ -653,11 +713,28 @@ insint(d, name, value)
}
}
static char zlib_module_documentation[]=
"The functions in this module allow compression and decompression "
"using the zlib library, which is based on GNU zip. \n\n"
"adler32(string) -- Compute an Adler-32 checksum.\n"
"adler32(string, start) -- Compute an Adler-32 checksum using a given starting value.\n"
"compress(string) -- Compress a string.\n"
"compress(string, level) -- Compress a string with the given level of compression (1--9).\n"
"compressobj([level]) -- Return a compressor object.\n"
"crc32(string) -- Compute a CRC-32 checksum.\n"
"crc32(string, start) -- Compute a CRC-32 checksum using a given starting value.\n"
"decompressobj([wbits]) -- Return a decompressor object (wbits=window buffer size).\n\n"
"Compressor objects support compress() and flush() methods; decompressor \n"
"objects support decompress() and flush()."
;
void
PyInit_zlib()
{
PyObject *m, *d;
m = Py_InitModule("zlib", zlib_methods);
m = Py_InitModule4("zlib", zlib_methods,
zlib_module_documentation,
(PyObject*)NULL,PYTHON_API_VERSION);
d = PyModule_GetDict(m);
ZlibError = Py_BuildValue("s", "zlib.error");
PyDict_SetItemString(d, "error", ZlibError);