class documentation

class DecompressingReader(object):

Constructor: DecompressingReader(f, decompressor)

View In Hierarchy

A helper class that helps with reading data selectively from a compressed stream.

Method __init__ The default constructor.
Method iter_read Read n bytes iteratively.
Method read Read up to n bytes.
Method read_n Read until n bytes have been read (or until EOF has been encountered).
Method reseek Re-seek the wrapped file object to match the last read position.
Method skip Skip the next n bytes.
Method skip_to Skip bytes until the specified offset is reached.
Instance Variable read_compressed number of compressed bytes read.
Instance Variable read_decompressed number of decompressed bytes read
Property total_compressed_size Return the total size of the compressed data stream so far.
Instance Variable _buffer Undocumented
Instance Variable _decompressor Undocumented
Instance Variable _f Undocumented
def __init__(self, f, decompressor):

The default constructor.

Parameters
f:file-likefile to read from
decompressor:decompressor-likea decompressor-like object to decompress the data
def iter_read(self, n=-1, buffersize=4096):

Read n bytes iteratively.

Parameters
n:intnumber of bytes to read. If smaller than 0, read until EOF.
buffersize:intsize of chunks to read at once
Yields
bytesthe data read (may be less than n)
def read(self, n, extra_decompress=0):

Read up to n bytes.

Similiar to file-like objects, this may return less bytes, but will return an empy string if and only if there's nothing left to read.

Parameters
n:intmaximum number of bytes to read
extra_decompress:intdecompress this many bytes more, mainly used for testing
Returns
strthe bytes read
def read_n(self, n):

Read until n bytes have been read (or until EOF has been encountered).

This method will attempt to always return exactly n bytes. However, should the EOF be encountered before this, less bytes may be returned.

Parameters
n:intnumber of bytes to read
Returns
strthe bytes read
def reseek(self, base_offset=0):

Re-seek the wrapped file object to match the last read position.

This should be called whenever some other code may have read/seeked the underlying file object.

Parameters
base_offset:intIf specified, take this offset within the underlying file object as the actual start of this wrapper.
def skip(self, n):

Skip the next n bytes.

This will also increase DecompressingReader.read_compressed and DecompressingReader.read_decompressed.

Parameters
n:intnumber of bytes to skip
def skip_to(self, offset):

Skip bytes until the specified offset is reached.

Parameters
offset:intoffset to skip to
Raises
IOErrorif offset points behind current position
read_compressed: int =

number of compressed bytes read.

read_decompressed: int =

number of decompressed bytes read

total_compressed_size: int =

Return the total size of the compressed data stream so far.

This only works if the compressor has read until the end.

_buffer =

Undocumented

_decompressor =

Undocumented

_f =

Undocumented