Transparently treating tar files and zip archives as directories

Skip Montanaro skip.montanaro at gmail.com
Sun Jan 6 17:29:26 EST 2019


I find it useful in some of the work I do to treat Zip archives as if
they were directories. I don't think it would be too difficult to make
it pretty much transparent, so that you could execute something like:

fileobj = magic_open("/path/to/some/archive.zip/some/internal/path/magic.txt")

or equivalent for writing and other list-y, glob-y sorts of things.
(In fact, I'd be mildly surprised if I couldn't find something on PyPI
if I spent a few minutes searching.)

As I considered that idea the other day, I thought, "Hmmm... might be
useful for tar files as well." Alas, the tarfile module API didn't
seem like it would support such a higher level API anywhere near as
easily. Is that a fundamental property/shortcoming of the tarfile
format, or is it just a function of the tarfile module's API?

Skip



More information about the Python-list mailing list