NetPluck
NetPluck is a tool allows you to remotely extract assets, typically files, from local and remote archives, such as a zip, without fetching or opening the entire archive. NetPluck was specifically designed to be used for very large .zip files that were stored in remote locations such as buckets on Backblaze and CDNs. It is extremely useful if you want to fetch the list of files or extract specific files of very large remote files.
If you intend to fetch and extract all the contents of the archive or your files are very small you don't need this library.
There are three key features of NetPluck:
- Works very efficiently on large files
- Can tell you what's in the file without reading the entire thing
- Extracts specific files without reading the entire thing
NetPluck provides a CLI tool via netpluck and the core python libraries.
Installation
To get access to local and http/https files you can run:
pip install netpluck
If you want access to buckets like Backblaze b2 or AWS S3, you must install the optional dependency:
pip install buckethandler
If you don't want to use pip and instead want to install locally via this copy (or want to contribute development) you can run the following after cloning and cd'ing into the repository.
pip install -e .
Formats Supported
- zip
- zip64
- tar
Protocols Supported
- Local Files
- Remote Files over HTTP or HTTPS that support range
- Backblaze B2
- AWS S3
Usage
Retrieving the List of Files in the Archive
netpluck --path mini.zip --toc
mini/
mini/empty.txt
mini/lava.png
mini/message.txt
mini/nova.bmp
mini/triangles.png
import netpluck
np = netpluck.NetPluck("mini.zip")
toc = np.get_file_list()
print(toc)
"""
['mini/', 'mini/empty.txt', 'mini/lava.png', 'mini/message.txt', 'mini/nova.bmp', 'mini/triangles.png']
"""
Extracting Files
You can pass regular expressions using --filter to extract files. If you do not specify the --out argument it will default to ./output/
netpluck --path mini.zip --filter="\.*bmp" --out ./output/
[1/1] 100.00% mini/nova.bmp => ./output/mini/nova.bmp
import netpluck
np = netpluck.NetPluck("mini.zip")
files = np.extract_from_filter(r"\.*.bmp","./output/")
"""
[1/1] 100.00% mini/nova.bmp => output\mini\nova.bmp
"""
print(files)
"""
['output\\mini\\nova.bmp']
"""
You can also use the --flatten flag if you want to strip all directories from the resulting output, this will dump all extracted matches into your output folder with no hierarchy.
Getting Statistics
You can enable the --stats flag to see data about bytes and lookups made.
netpluck --path mini.zip --stats --filter="\.*txt" --out ./output/
[1/2] 50.00% empty.txt => ./output/mini/empty.txt
[2/2] 100.00% message.txt => ./output/mini/message.txt
File size: 1.52MB
Cache hits: 7 size: 1.37KB
Uncached reads: 3 size: 64.10KB
Bytes saved: 1.46MB 95.88%
In this instance we read 64kb of the 1556kb file while extracting the two txt files.
Extending
Adding New Protocols and Archives
Protocols in NetPluck are handled by a prefix like: https:// or b2:// to add new ones you must modify the netpluck.py main class and ProtocolType enum. Make sure you modify the _guess_protocol method so it can automatically determine the appropriate one.
Archive types can be extended by adding your own handler to netpluck/virtual_archive and subclassing the VirtualArchive. Be sure to implement all interfaces exposed by VirtualArchive. See the existing zip archive handler for an example. Typically this means you implement __init__ and _read_uncached_range. See netpluck/virtual_file/local.py or netpluck/virtual_file/http.py for a simple example.
You may also need to add a new virtual file type depending on how your data is queried which can be done just like VirtualArchive but with VirtualFile.
Metadata
Release files for netpluck 0.9.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| netpluck-0.9.4.tar.gz | 17.9 kB | Without provenance | Details for netpluck-0.9.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| netpluck-0.9.4-py3-none-any.whl | Python 3 | none | any | Details for netpluck-0.9.4-py3-none-any.whl |
Total release size: 36.3 kB
Release files / netpluck-0.9.4.tar.gz
| Download URL | netpluck-0.9.4.tar.gz |
|---|---|
| Size | 17.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ba1288ac4f66c0a0fbadbb5a2e23a67cfd51daad28fc123af72c5e7be1151faa
|
|
BLAKE2b-256 checksum How to use checksums |
2601c6abc07ad37f5ea39f06c5014e38374c8f8123b45383e152694524b1a66c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.11
|
Release files / netpluck-0.9.4-py3-none-any.whl
| Download URL | netpluck-0.9.4-py3-none-any.whl |
|---|---|
| Size | 18.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d65d2bae803247da2bd528e2253acb3a36413bd848ca3c88b03de6b370995bf8
|
|
BLAKE2b-256 checksum How to use checksums |
f952951bf62ab929de1c256ae53b70d5f2419182597c9d390d3d66d4e3f25130
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.11
|
Security for netpluck 0.9.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.