dfvfs icon indicating copy to clipboard operation
dfvfs copied to clipboard

Improve archive file support

Open joachimmetz opened this issue 8 years ago • 3 comments

Add Improve archive file support for:

joachimmetz avatar Jan 08 '16 07:01 joachimmetz

FYI, I have a fairly extensive support for archive extraction through a libarchive ctypes binding and 7zip subprocesses and the Python stdlib here: https://github.com/nexB/scancode-toolkit/tree/develop/src/extractcode It may or may not be useful to you and it may or give you some ideas.

pombredanne avatar Mar 18 '17 07:03 pombredanne

@pombredanne thanks I'll give it a look

joachimmetz avatar Mar 18 '17 09:03 joachimmetz

https://github.com/libarchive/libarchive The license is a bit messy, mainly BSD 2-clause, some BSD 3-clause, public domain.

Then there appear to be 3 different projects that provide Python bindings

  • https://pypi.org/project/libarchive/ (GPL 2)
  • https://pypi.org/project/libarchive-c/ (CC0)
  • https://pypi.org/project/python-libarchive/ (BSD)

Fedora and Ubuntu ship with python3-libarchive-c unfortunately this is public domain, no FOSS license, so treat it as an optional dependency for now.

It support reading from file-like objects

f = open('syslog.zip', 'rb')
with libarchive.stream_reader(f) as r:
    for e in r:
        print(e)

Looks like a seekable_stream_reader was added very recently https://github.com/Changaco/python-libarchive-c/blame/master/libarchive/read.py#L142

joachimmetz avatar Dec 31 '20 12:12 joachimmetz