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
-
Bump the version number in setup.py.
-
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
- Install twine
pip3 install twine
- Upload the compiled wheels and the source code to PyPI:
python3 setup.py sdist --dist-dir wheels
python3 -m twine upload wheels/*
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Hashes for lzip-0.1.0-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7d98e7c60ff62322f1035fc3e34391eaea29c3a8d491e1ef3211aa72a015ae40 |
|
MD5 | 7df2fb579bdde9e25a99e45eaa9cd7cf |
|
BLAKE2b-256 | a7dc13c036dba2a18b7aa6c427e41aaad18c8e0d42d2c987fea7318a946852de |
Hashes for lzip-0.1.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f5d076673c9374db49f76ef018a0a3964d0e5172eefc3d2079cf34f57d53984d |
|
MD5 | b9e1aaaa2586bf0906e2fa0ff15382c1 |
|
BLAKE2b-256 | 54575acb41665db1f9bd27295fb308d07155a723795aee2256f042c4e32c4cb9 |
Hashes for lzip-0.1.0-cp39-cp39-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 67004791cf40ab22b1f9a10f4779fedd7215974c88ab4e9a39111667c7ba7e3b |
|
MD5 | 4d6c402f6154ff8de0d44beb2015f33a |
|
BLAKE2b-256 | bd9d67bd46e7106ca5bd5df6ead17f2b328bdfaaded336edde9e1bfd36039329 |
Hashes for lzip-0.1.0-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 403472e93a1ff7719ad1f8eabef59761bb94755686cdb01db965c71d2e05ae2c |
|
MD5 | 9737efede3cd2c825f1bda69c83f670a |
|
BLAKE2b-256 | a2f5ae775c76089fb44136289d9d6f99cf100213a4b3b602e320fe2b02d5ae54 |
Hashes for lzip-0.1.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 56e504cf6adbb17bde32bb69adbe348d58b7e81da08b555f16b5b3c3b6897fda |
|
MD5 | 619e017db9b3360f90da8a329251a9fa |
|
BLAKE2b-256 | 3aa82612b43746584c45e652c3b59d451b59557fc6569b0ee5b54beb4b593aa3 |
Hashes for lzip-0.1.0-cp38-cp38-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c360fdf81d04f5bf0de9d5b874595281a939ae190932f092dbd6670fecd6ad12 |
|
MD5 | 9f94ed3bb2bacf9237b47bc3e97d2c02 |
|
BLAKE2b-256 | b5dcc78491960c56fd090aa2a33882a1719d82bb33ba83c8aa611721aceb7f3a |
Hashes for lzip-0.1.0-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d1838b6286d921a07fbfa469f12087339c2a31cbb62a6cd1bd0498917b0b168e |
|
MD5 | 16448e27e407976b5cff031ed756dbb3 |
|
BLAKE2b-256 | 7be2a38865f815451cb16d0d0aded93bb34c9979afdeb37021af50a47e8ca8df |
Hashes for lzip-0.1.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | eac5b01f11f333bb35ef5460dda9699f3a0489e1a8bb35773532eaa7b9417dd4 |
|
MD5 | 3deac97e034d86c04ee37ad01f5aba9f |
|
BLAKE2b-256 | 2d2f87a8b9df2980a5659d1f29091b6bed0f0da27c0797260c30a26cafd1fa1e |
Hashes for lzip-0.1.0-cp37-cp37m-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 63ff29aa590b8e0ab15216077dacd9fda36fba4cc9a421c5aed65f101f4fee32 |
|
MD5 | e80164997fce0169277578c324be7cd1 |
|
BLAKE2b-256 | fede4fca20d8eca069667c712230b109755f5fa73f004401d3c6d85513aa80da |