Skip to main content

This code has been transpiled from ipfs-unixfs-exporter and has minimal changes.

Usage

DAG-PB, Raw, DAG-CBOR, and Identity codecs are supported.

>>> from unix_fs_exporter import UnixFSFile, UnixFSDirectory, RawNode, ObjectNode, IdentityNode

Given a block store and a root cid, decode the underlying data.

>>> from unix_fs_exporter import RawNode, export, BlockStore
>>> from multiformats import CID, multicodec, multihash
...
>>> class SomeBlockStore(BlockStore):
...     def __init__(self):
...         self.mapping = dict()
...
...     async def get_block(self, cid):
...         return self.mapping[cid.digest]
...
>>> data = b'some data'
>>> mh = multihash.get('sha2-256').digest(data)
>>> cid = CID('base32', 1, 'raw', mh)
>>> block_store = SomeBlockStore()
>>> block_store.mapping[cid.digest] = data
...
>>> async def test():
...     result = await export(cid, block_store)
...     assert isinstance(result, RawNode)
...
...     async for chunk in result.content:
...         print(chunk)
...
>>> asyncio.run(test())
b'some data'

Recursively iterate through a directory.

>>> from unix_fs_exporter import recursive_export, UnixFSFile
>>> # Creation of the blockstore is an exercise left to the reader
>>> async def test():
...     entries = recursive_export('bafybeifpaez32hlrz5tmr7scndxtjgw3auuloyuyxblynqmjw5saapewmu', block_store)
...     async for entry in entries:
...         assert isinstance(entry, UnixFSFile)
...         async for chunk in entry.content:
...             assert isinstance(chunk, bytes)
>>> asyncio.run(test())

Metadata

Release files for unix-fs-exporter 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for unix-fs-exporter 0.2.0
File Size Uploaded Provenance Actions
unix_fs_exporter-0.2.0.tar.gz 16.7 kB Without provenance Details for unix_fs_exporter-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for unix-fs-exporter 0.2.0
File Interpreter ABI Platform Actions
unix_fs_exporter-0.2.0-py3-none-any.whl Python 3 none any Details for unix_fs_exporter-0.2.0-py3-none-any.whl

Total release size: 31.1 kB

Release files / unix_fs_exporter-0.2.0.tar.gz

Download URL unix_fs_exporter-0.2.0.tar.gz
Size 16.7 kB
Tags Source
SHA-256 checksum
How to use checksums
4e7dbbefefd07e77d04ebfd7969dc53732d28ef67f1c0ca7231be9b5053be970
BLAKE2b-256 checksum
How to use checksums
6bfc3df92158d750fb43febf324e943a32e402adfaa3e2246ee9d0bf7cc142dd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.12

Release files / unix_fs_exporter-0.2.0-py3-none-any.whl

Download URL unix_fs_exporter-0.2.0-py3-none-any.whl
Size 14.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
734144c8ed87cad87cc80c58f343983700582614ea4ca5c88b7f0006dd521138
BLAKE2b-256 checksum
How to use checksums
fbe1f65aa65d368f672abfaae41eea8e541ef7afbb1065a6bfb40768295636e5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.12

Security for unix-fs-exporter 0.2.0

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.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page