MCPcopy Create free account
hub / github.com/ActiveState/code / read

Method read

recipes/Python/492209_dal1py/recipe-492209.py:26–37  ·  view source on GitHub ↗
(self, index, size)

Source from the content-addressed store, hash-verified

24
25 # Read Some Data
26 def read(self, index, size):
27 assert type(index) is int and 0 <= index < self.__end
28 assert type(size) is int and index < index + size <= self.__end
29 first_index = index
30 last_index = index + size - 1
31 first_block = first_index / self.__size + 1
32 last_block = last_index / self.__size + 2
33 stream = ''.join([self.__read(block) for block in \
34 range(first_block, last_block)])
35 first_index = index % self.__size
36 last_index = first_index + size
37 return stream[first_index:last_index]
38
39 # Write Some Data
40 def write(self, index, data):

Callers 2

testFunction · 0.95
__readMethod · 0.45

Calls 3

__readMethod · 0.95
rangeFunction · 0.85
joinMethod · 0.45

Tested by

no test coverage detected