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
Metadata
Release files for ipld-car 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| ipld_car-0.0.1.tar.gz | 7.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| ipld_car-0.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 15.5 kB
Release files / ipld_car-0.0.1.tar.gz
| Download URL | ipld_car-0.0.1.tar.gz |
|---|---|
| Size | 7.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d6257f18f6f69ea83a72ae1309c48ac38977b969cfb93b7e9a95508892c54043
|
|
BLAKE2b-256 checksum How to use checksums |
205fd75282394109d41e95af847c7373292f7b526e34e21d6c6d65e5521233e2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.2
|
Release files / ipld_car-0.0.1-py3-none-any.whl
| Download URL | ipld_car-0.0.1-py3-none-any.whl |
|---|---|
| Size | 7.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
13cbc192a4e21b906d0f9c8b10506ca9332ead6091ad1ae8fe4d6f2415864477
|
|
BLAKE2b-256 checksum How to use checksums |
c246c223e8f8f492df8c688073f7df4fa32cf525781907c8237b5eb9abcf1546
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.2
|