lzw.PagingDecoder

Package lzw :: Class PagingDecoder |
[frames] | no frames]

# Class PagingDecoder

source code

    object --+
             |
            PagingDecoder

UNTESTED. Dual of PagingEncoder, knows how to handle independantly encoded, END_OF_INFO_CODE delimited chunks of an inbound byte stream

Instance Methods
__init__(self, initial_code_size) x.__init__(...) initializes x; see x.__class__.__doc__ for signature | source code
next_page(self, codepoints) Iterator over the next page of codepoints. | source code
decodepages(self, bytesource) Takes an iterator of bytes, returns an iterator of iterators of uncompressed data. | source code
Inherited from `object`: `__delattr__`, `__format__`, `__getattribute__`, `__hash__`, `__new__`, `__reduce__`, `__reduce_ex__`, `__repr__`, `__setattr__`, `__sizeof__`, `__str__`, `__subclasshook__`

Properties
Inherited from `object`: `__class__`

Method Details

### __init__(self, initial_code_size) (Constructor) | source code
x.__init__(...) initializes x; see x.__class__.__doc__ for signature Overrides: object.__init__ (inherited documentation)

### decodepages(self, bytesource) | source code
Takes an iterator of bytes, returns an iterator of iterators of uncompressed data. Expects input to conform to the output conventions of PagingEncoder(), in particular that "pages" are separated with an END_OF_INFO_CODE and padding up to the next byte boundary. BUG: Dangling trailing page on decompression.
    >>> import lzw
    >>> pgdec = lzw.PagingDecoder(initial_code_size=257)
    >>> pgdecoded = pgdec.decodepages(
    ...     ''.join([ '\x80\x1c\xcc\'\x91\x01\xa0\xc2m6',
    ...               '\x99NB\x03\xc9\xbe\x0b\x07\x84\xc2',
    ...               '\xcd\xa68|"\x14 3\xc3\xa0\xd1c\x94',
    ...               '\x02\x02\x80\x18M\xc6A\x01\xd0\xd0e',
    ...               '\x10\x1c\x8c\xa73\xa0\x80\xc7\x02\x10',
    ...               '\x19\xcd\xe2\x08\x14\x10\xe0l0\x9e`\x10',
    ...               '\x10\x80\x18\xcc&\xe19\xd0@t7\x9dLf\x889',
    ...               '\xa0\xd2s\x80@@' ])
    ... )
    >>> [ b"".join(pg) for pg in pgdecoded ]
    ['say hammer yo hammer mc hammer go hammer', 'and the rest can go and play', "can't touch this", '']