OpenQuizz
Une application de gestion des contenus pédagogiques
DeltaApplyReader Class Reference
Inheritance diagram for DeltaApplyReader:
Collaboration diagram for DeltaApplyReader:

Public Member Functions

def __init__ (self, stream_list)
 
def read (self, count=0)
 
def seek (self, offset, whence=getattr(os, 'SEEK_SET', 0))
 
def new (cls, stream_list)
 
def type (self)
 
def type_id (self)
 
def size (self)
 
- Public Member Functions inherited from LazyMixin
def __getattr__ (self, attr)
 

Static Public Attributes

 k_max_memory_move
 

Detailed Description

A reader which dynamically applies pack deltas to a base object, keeping the
memory demands to a minimum.

The size of the final object is only obtainable once all deltas have been
applied, unless it is retrieved from a pack index.

The uncompressed Delta has the following layout (MSB being a most significant
bit encoded dynamic size):

* MSB Source Size - the size of the base against which the delta was created
* MSB Target Size - the size of the resulting data after the delta was applied
* A list of one byte commands (cmd) which are followed by a specific protocol:

 * cmd & 0x80 - copy delta_data[offset:offset+size]

  * Followed by an encoded offset into the delta data
  * Followed by an encoded size of the chunk to copy

 *  cmd & 0x7f - insert

  * insert cmd bytes from the delta buffer into the output stream

 * cmd == 0 - invalid operation ( or error in delta stream )

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self,
  stream_list 
)
Initialize this instance with a list of streams, the first stream being
the delta to apply on top of all following deltas, the last stream being the
base object onto which to apply the deltas

Member Function Documentation

◆ new()

def new (   cls,
  stream_list 
)
Convert the given list of streams into a stream which resolves deltas
when reading from it.

:param stream_list: two or more stream objects, first stream is a Delta
    to the object that you want to resolve, followed by N additional delta
    streams. The list's last stream must be a non-delta stream.

:return: Non-Delta OPackStream object whose stream can be used to obtain
    the decompressed resolved data
:raise ValueError: if the stream list cannot be handled

◆ read()

def read (   self,
  count = 0 
)

◆ seek()

def seek (   self,
  offset,
  whence = getattr(os, 'SEEK_SET', 0) 
)
Allows to reset the stream to restart reading

:raise ValueError: If offset and whence are not 0

◆ size()

def size (   self)
:return: number of uncompressed bytes in the stream

◆ type()

def type (   self)

◆ type_id()

def type_id (   self)

Field Documentation

◆ k_max_memory_move

k_max_memory_move
static

The documentation for this class was generated from the following file: