Skip to main content

decompress lzip archives

Project description

Lzip

A simple Python library to decode Lzip archives chunk by chunk. See https://www.nongnu.org/lzip/ for details on the Lzip format.

pip3 install lzip

Documentation

The decoder class can be used to read the chunks in a file:

import lzip

for chunk in lzip.decoder('/path/to/archive.lz'):
    # process chunk

chunk is a byte sequence (https://docs.python.org/3/library/stdtypes.html#bytes).

Since decoder is an iterator, the chunks can also be loaded as follows:

import lzip

chunk_iterator = iter(lzip.decoder('/path/to/archive.lz'))

chunk_0 = next(chunk_iterator)
chunk_1 = next(chunk_iterator)
...
chunk_n = next(chunk_iterator)

When the end of the archive is reached, next(chunk_iterator) raises a StopIteration exception.

The size of each chunk is around 64 KiB and varies from one chunk to the next. To facilitate the parsing (post Lzip-decoding) of files that use fixed-sized words, decoder takes an optional parameter chunk_factor. The size of each chunk is still variable, but is guaranteed to be a multipe of chunk_factor. If the total size n of the archive is not a multiple of chunk_factor, the last n - int(n / chunk_factor) * chunk_factor bytes are dropped.

The following example decodes the archive '/path/to/archive.lz' and converts the decoded bytes to 4-bytes unsigned integers:

import lzip
import numpy

for chunk in lzip.decoder('/path/to/archive.lz', 4):
    values = numpy.frombuffer(chunk, dtype='<u4')

Publish

  1. Bump the version number in setup.py.

  2. Install Cubuzoa in a different directory (https://github.com/neuromorphicsystems/cubuzoa) to build pre-compiled versions for all major operating systems. Cubuzoa depends on VirtualBox (with its extension pack) and requires about 75 GB of free disk space.

cd cubuzoa
python3 cubuzoa.py provision
python3 cubuzoa.py build /path/to/event_stream
  1. Install twine
pip3 install twine
  1. Upload the compiled wheels and the source code to PyPI:
python3 setup.py sdist --dist-dir wheels
python3 -m twine upload wheels/*

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lzip-0.1.0.tar.gz (8.3 kB view hashes)

Uploaded Source

Built Distributions

lzip-0.1.0-cp39-cp39-win_amd64.whl (28.2 kB view hashes)

Uploaded CPython 3.9 Windows x86-64

lzip-0.1.0-cp39-cp39-win32.whl (24.1 kB view hashes)

Uploaded CPython 3.9 Windows x86

lzip-0.1.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (47.4 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

lzip-0.1.0-cp39-cp39-macosx_11_0_x86_64.whl (46.2 kB view hashes)

Uploaded CPython 3.9 macOS 11.0+ x86-64

lzip-0.1.0-cp38-cp38-win_amd64.whl (28.1 kB view hashes)

Uploaded CPython 3.8 Windows x86-64

lzip-0.1.0-cp38-cp38-win32.whl (24.1 kB view hashes)

Uploaded CPython 3.8 Windows x86

lzip-0.1.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (47.4 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

lzip-0.1.0-cp38-cp38-macosx_11_0_x86_64.whl (46.2 kB view hashes)

Uploaded CPython 3.8 macOS 11.0+ x86-64

lzip-0.1.0-cp37-cp37m-win_amd64.whl (28.0 kB view hashes)

Uploaded CPython 3.7m Windows x86-64

lzip-0.1.0-cp37-cp37m-win32.whl (24.1 kB view hashes)

Uploaded CPython 3.7m Windows x86

lzip-0.1.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (47.4 kB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.17+ x86-64

lzip-0.1.0-cp37-cp37m-macosx_11_0_x86_64.whl (46.2 kB view hashes)

Uploaded CPython 3.7m macOS 11.0+ x86-64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page