Content Addressable aRchive format reader and writer.
Project description
py-ipld-car
Content Addressable aRchive format reader and writer.
Install
pip install ipld_car
Usage
import ipld_car
from multiformats import multihash, CID
data = bytes([1, 2, 3])
digest = multihash.digest(data, "sha2-256")
cid = CID("base32", 1, "raw", digest)
block = (cid, data)
# encode a CAR file
car = ipld_car.encode([block[0]], [block])
print("CAR: ")
print(" " + str(car.tobytes()))
# decode a CAR file
roots, blocks = ipld_car.decode(car)
print("===")
print("Roots:")
for r in roots:
print(" " + r.encode("base32"))
print("Blocks:")
for b in blocks:
print(" CID: " + b[0].encode("base32"))
print(" Bytes: " + str(b[1].tobytes()))
# Output:
#
# CAR:
# b":\xa2eroots\x81\xd8*X%\x00\x01U\x12 \x03\x90X\xc6\xf2\xc0\xcbI,S;\nM\x14\xefw\xcc\x0fx\xab\xcc\xce\xd5(}\x84\xa1\xa2\x01\x1c\xfb\x81gversion\x01'\x01U\x12 \x03\x90X\xc6\xf2\xc0\xcbI,S;\nM\x14\xefw\xcc\x0fx\xab\xcc\xce\xd5(}\x84\xa1\xa2\x01\x1c\xfb\x81\x01\x02\x03"
# ===
# Roots:
# bafkreiadsbmmn4waznesyuz3bjgrj33xzqhxrk6mz3ksq7meugrachh3qe
# Blocks:
# CID: bafkreiadsbmmn4waznesyuz3bjgrj33xzqhxrk6mz3ksq7meugrachh3qe
# Bytes: b'\x01\x02\x03'
Contributing
All welcome! storacha.network is open-source.
License
Dual-licensed under Apache-2.0 OR MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
ipld_car-0.0.1.tar.gz
(7.9 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ipld_car-0.0.1.tar.gz.
File metadata
- Download URL: ipld_car-0.0.1.tar.gz
- Upload date:
- Size: 7.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d6257f18f6f69ea83a72ae1309c48ac38977b969cfb93b7e9a95508892c54043
|
|
| MD5 |
70443d5c1675adf252c1b307e719ace3
|
|
| BLAKE2b-256 |
205fd75282394109d41e95af847c7373292f7b526e34e21d6c6d65e5521233e2
|
File details
Details for the file ipld_car-0.0.1-py3-none-any.whl.
File metadata
- Download URL: ipld_car-0.0.1-py3-none-any.whl
- Upload date:
- Size: 7.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
13cbc192a4e21b906d0f9c8b10506ca9332ead6091ad1ae8fe4d6f2415864477
|
|
| MD5 |
2960a4e86ac47be1ab14f19e4f4579ca
|
|
| BLAKE2b-256 |
c246c223e8f8f492df8c688073f7df4fa32cf525781907c8237b5eb9abcf1546
|