Debian Codegraph @

pypy/module/zlib/moduledef.py

raw symbols SCIP
1
2 """
3 Mixed-module definition for the zlib module.
4 """
5
6 from pypy.interpreter.mixedmodule import MixedModule
7 from rpython.rlib import rzlib
8
9
10 class Module(MixedModule):
11 """\
12 The functions in this module allow compression and decompression using the
13 zlib library, which is based on GNU zip.
14
15 adler32(string[, start]) -- Compute an Adler-32 checksum.
16 compress(string[, level]) -- Compress string, with compression level in 1-9.
17 compressobj([level]) -- Return a compressor object.
18 crc32(string[, start]) -- Compute a CRC-32 checksum.
19 decompress(string,[wbits],[bufsize]) -- Decompresses a compressed string.
20 decompressobj([wbits]) -- Return a decompressor object.
21
22 'wbits' is window buffer size.
23 Compressor objects support compress() and flush() methods; decompressor
24 objects support decompress() and flush()."""
25
26 interpleveldefs = {
27 'crc32': 'interp_zlib.crc32',
28 'adler32': 'interp_zlib.adler32',
29 'compressobj': 'interp_zlib.Compress',
30 'decompressobj': 'interp_zlib.Decompress',
31 'compress': 'interp_zlib.compress',
32 'decompress': 'interp_zlib.decompress',
33 'DEF_BUF_SIZE': 'interp_zlib.default_buffer_size(space)',
34 '__version__': 'space.newtext("1.0")',
35 'error': 'space.fromcache(interp_zlib.Cache).w_error',
36 }
37
38 appleveldefs = {
39 }
40
41 def setup_after_space_initialization(self):
42 space = self.space
43 space.setattr(self, space.wrap('ZLIB_RUNTIME_VERSION'),
44 space.wrap(rzlib.zlibVersion()))
45
46
47
48 for _name in """
49 MAX_WBITS DEFLATED DEF_MEM_LEVEL
50 Z_BEST_SPEED Z_BEST_COMPRESSION Z_DEFAULT_COMPRESSION
51 Z_FILTERED Z_HUFFMAN_ONLY Z_DEFAULT_STRATEGY
52 Z_FINISH Z_NO_FLUSH Z_SYNC_FLUSH Z_FULL_FLUSH
53 ZLIB_VERSION
54 """.split():
55 Module.interpleveldefs[_name] = 'space.wrap(%r)' % (getattr(rzlib, _name),)
56
57
58 for _name in """
59 Z_NO_COMPRESSION Z_RLE Z_PARTIAL_FLUSH Z_FIXED Z_BLOCK Z_TREES
60 """.split():
61 Module.interpleveldefs[_name] = 'space.newint(interp_zlib.%s)' % _name