Skip to main content

os.walk interface for nested zipfiles

Project description

zipwalk

A very simple walker that recursively walks through nested zipfiles

About

This project was created because I needed a way to iterate over nested zipfiles without unzipping them.

Install

pip install zipwalk

Usage

It has a similar interface to os.walk:

from zipwalk import zipwalk

for root, zips, files in zipwalk('tests/1.zip'):
    print('root:', root.filename)
    print('zips:', zips)
    print('files:', files)

# output:
# root: tests/1.zip
# zips: {'2.zip'}
# files: {'1c.txt', 'dir/d1.txt', '1b.txt', '1a.txt'}
# root: 2.zip
# zips: set()
# files: {'2c.txt', '2b.txt', '2a.txt'}

root is an ZipFile instance opened on read mode, r. All zip files are opened using with context manager and will be closed once the generator is exhausted.

You can use the zip walker like the following:

from pathlib import Path
from zipfile import ZipFile

from zipwalk import zipwalk

zipwalk(ZipFile('tests/1.zip'))
zipwalk(Path('tests/1.zip'))
zipwalk('tests/1.zip')

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

zipwalk-0.1.4.tar.gz (1.6 kB view details)

Uploaded Source

Built Distribution

zipwalk-0.1.4-py3-none-any.whl (1.9 kB view details)

Uploaded Python 3

File details

Details for the file zipwalk-0.1.4.tar.gz.

File metadata

  • Download URL: zipwalk-0.1.4.tar.gz
  • Upload date:
  • Size: 1.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for zipwalk-0.1.4.tar.gz
Algorithm Hash digest
SHA256 e4df4b41d9502c9b39e56c4d815561a79ce304a9c707abb0a8fb4f8389cda7d4
MD5 f1662cf5012e4316b8d08a678d21ee01
BLAKE2b-256 d87b63683a2300417ce70972aaa1338b97e509263423e5a6b87a3171aff2f323

See more details on using hashes here.

File details

Details for the file zipwalk-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: zipwalk-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 1.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for zipwalk-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 0317ae333e304e9fc2a7caf50e2e5198aaca8a022baa17d87335cb207133262c
MD5 b400a03c2bd014dc16f0fb624763bc41
BLAKE2b-256 0e7fe160da735e5d3106ac15502e5a0a73384b0109576f61185ce170f153ea9c

See more details on using hashes here.

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