oneroan
oneroan

Reputation: 121

On Circuitpython, how to decompress files from tar or gzip file?

I can use utarfile.py to untar a file on Micropython.

But for circuitpython, even the latest 8.0.0 beta2. There is no circuitpython version of utar, gzip library, or something like that. If I use the uarfile.py, there is also no uctypes modules on circuitpython.

Could anybody tell me how to decompress a tar or gzip file on Circuitpython. Thank you.

Upvotes: 1

Views: 251

Answers (2)

Jon Nordby
Jon Nordby

Reputation: 6289

There is now also an implementation of zipfile ported from CPython. This supports ZIP archives (that are deflate/zlib compressed). Tested on MicroPython 1.23, but will hopefully work on CircuitPython as well. https://github.com/jonnor/micropython-zipfile

Upvotes: 0

rickyosser
rickyosser

Reputation: 11

I had the same problem and thought of taking a look at tarfile in the MicroPython std-lib.

As noted in the question uCtypes aren't supported in CircuitPython which means I had to replace those instances in the code with the standard python-struct which is supported in CircuitPython.

The version that I created should be fully portable to any Python3 and above and thus provides a way of unarchiving an uncompressed tar-archive without any external dependencies.

I have published the pure implementation on github at: https://github.com/rickyosser/tarfile

Upvotes: 1

Related Questions