Debian Codegraph @

tests/frame/helpers.py

raw symbols SCIP
1 import lz4.frame as lz4frame
2
3
4 def get_frame_info_check(compressed_data,
5 source_size,
6 store_size,
7 block_size,
8 block_linked,
9 content_checksum,
10 block_checksum):
11
12 frame_info = lz4frame.get_frame_info(compressed_data)
13
14 assert frame_info["content_checksum"] == content_checksum
15 assert frame_info["block_checksum"] == block_checksum
16
17 assert frame_info["skippable"] is False
18
19 if store_size is True:
20 assert frame_info["content_size"] == source_size
21 else:
22 assert frame_info["content_size"] == 0
23
24 if source_size > frame_info['block_size']:
25 # More than a single block
26 assert frame_info["block_linked"] == block_linked
27
28 if block_size == lz4frame.BLOCKSIZE_DEFAULT:
29 assert frame_info["block_size_id"] == lz4frame.BLOCKSIZE_MAX64KB
30 else:
31 assert frame_info["block_size_id"] == block_size
32
33
34 def get_chunked(data, nchunks):
35 size = len(data)
36 # stride = int(math.ceil(float(size)/nchunks)) # no // on py 2.6
37 stride = size // nchunks
38 start = 0
39 end = start + stride
40 while end < size:
41 yield data[start:end]
42 start += stride
43 end += stride
44 yield data[start:]