Python API¶
itar.open returns an IndexedTarFile, a mapping-like view that streams members directly from the underlying tar shards. Use it as a context manager and access members like dictionary values.
itar ¶
IndexedTarFile ¶
Bases: Mapping
Read-only mapping that serves members out of indexed tar shards.
| PARAMETER | DESCRIPTION |
|---|---|
shards
|
Shard sources (single tar, list of tars, or resolver callable).
TYPE:
|
index
|
Precomputed index mapping member names to offsets.
TYPE:
|
open_fn
|
Optional callable to open paths; defaults to a thread-safe file reader. |
buffered_file_reader
|
Wrap member streams in a buffered reader when True.
TYPE:
|
Use itar.open to construct this class. It supports the mapping protocol
for read access (archive["path/to/file"]) and should be used as a
context manager to close any open file handles.
Example
check_tar_index ¶
Validate stored offsets for the given names (or all members).
These helpers are the public surface for building and loading .itar indexes.
itar.index ¶
create ¶
create(path: str | PathLike, shards: list[Shard] | Shard, *, progress_bar: bool = True) -> IndexedTarIndex
Build an index for shards and save it to path.
open ¶
open(path: str | PathLike, shards: list[Shard] | Shard | None = None, open_fn: Callable[[str | PathLike], IO[bytes]] | None = None, buffered_file_reader: bool = True) -> IndexedTarFile
Open an IndexedTarFile using an on-disk index file.
build ¶
Build an index mapping without instantiating IndexedTarFile.
dump ¶
Persist index to disk in msgpack format.
load ¶
Load an index dictionary from a saved .itar index file.