Esempio n. 1
0
    def _seek(self, index, offsets=None):
        data_stream = self._data_stream
        data_base = self._data_base

        if offsets is None:
            offset = self.offsetof(index)
        else:
            offset = offsets[sequence_index(index, len(offsets))]

        data_stream.seek(data_base + offset)
Esempio n. 2
0
    def _seek(self, index, offsets=None):
        data_stream = self._data_stream
        data_base = self._data_base

        if offsets is None:
            offset = self.offsetof(index)
        else:
            offset = offsets[sequence_index(index, len(offsets))]

        data_stream.seek(data_base + offset)
Esempio n. 3
0
    def extract_chunk(self, index):
        chunk_count = self._chunk_count
        data_stream = self._data_stream
        huffman_nodes = self._huffman_nodes
        index = sequence_index(index, chunk_count)

        chunk = b''
        chunk_size = self.sizeof(index)
        if chunk_size:
            self._seek(index)
            compressed_size, expanded_size = self._read_sizes(index)
            chunk = stream_read(data_stream, compressed_size)
            chunk = huffman_expand(chunk, expanded_size, huffman_nodes)
        return chunk
Esempio n. 4
0
    def extract_chunk(self, index):
        self._log_extract_chunk(index)
        chunk_count = self._chunk_count
        data_stream = self._data_stream
        huffman_nodes = self._huffman_nodes
        index = sequence_index(index, chunk_count)

        chunk = b''
        chunk_size = self.sizeof(index)
        if chunk_size:
            self._seek(index)
            compressed_size, expanded_size = self._read_sizes(index)
            chunk = stream_read(data_stream, compressed_size)
            chunk = huffman_expand(chunk, expanded_size, huffman_nodes)
        return chunk
Esempio n. 5
0
 def sizeof(self, index):
     chunk_offsets = self._chunk_offsets
     index = sequence_index(index, len(self))
     return chunk_offsets[index + 1] - chunk_offsets[index]
Esempio n. 6
0
 def offsetof(self, index):
     return self._chunk_offsets[sequence_index(index, len(self))]
Esempio n. 7
0
 def sizeof(self, index):
     chunk_offsets = self._chunk_offsets
     index = sequence_index(index, self._chunk_count)
     return chunk_offsets[index + 1] - chunk_offsets[index]
Esempio n. 8
0
 def offsetof(self, index):
     return self._chunk_offsets[sequence_index(index, self._chunk_count)]