equal
deleted
inserted
replaced
34 indexformatng = ">Qiiiiii20s12x" |
34 indexformatng = ">Qiiiiii20s12x" |
35 |
35 |
36 s = struct.calcsize(indexformatng) |
36 s = struct.calcsize(indexformatng) |
37 index = [] |
37 index = [] |
38 cache = None |
38 cache = None |
39 n = off = 0 |
39 off = 0 |
40 |
40 |
41 l = len(data) - s |
41 l = len(data) - s |
42 append = index.append |
42 append = index.append |
43 if inline: |
43 if inline: |
44 cache = (0, data) |
44 cache = (0, data) |
45 while off <= l: |
45 while off <= l: |
46 e = _unpack(indexformatng, data[off:off + s]) |
46 e = _unpack(indexformatng, data[off:off + s]) |
47 append(e) |
47 append(e) |
48 n += 1 |
|
49 if e[1] < 0: |
48 if e[1] < 0: |
50 break |
49 break |
51 off += e[1] + s |
50 off += e[1] + s |
52 else: |
51 else: |
53 while off <= l: |
52 while off <= l: |
54 e = _unpack(indexformatng, data[off:off + s]) |
53 e = _unpack(indexformatng, data[off:off + s]) |
55 append(e) |
54 append(e) |
56 n += 1 |
|
57 off += s |
55 off += s |
58 |
56 |
59 if off != len(data): |
57 if off != len(data): |
60 raise ValueError('corrupt index file') |
58 raise ValueError('corrupt index file') |
61 |
59 |