Skip to main content

iokit

Python library for serialization and file operations. Unifies multiple format codecs (JSON, YAML, Tar, etc.) with a single State interface that combines data, path, and timestamp.

Installation

Base install covers txt, bin, dat, json, gz, zip, tar:

pip install iokit

For all formats and web download support:

pip install iokit[ultra]

Missing formats will tell you what to install:

from iokit import Yaml
Yaml({"key": "value"}, "file")
ModuleNotFoundError: Missing required packages: PyYAML>=6.0.1. Install with: pip install PyYAML

Quick Start

Work with data as States. Each State carries the data, a path, and a timestamp. Load and save without thinking about formats.

JSON file:

from iokit import Json

state = Json({"key": "value"}, path="config.json")
print(state.path)      # config.json
print(state.size)      # 16
print(state.load())    # {'key': 'value'}

Text file:

from iokit import Txt

state = Txt("Hello, World!", "message")
state.save("/tmp/data", parents=True)

Load any file from disk:

from iokit import file

state = file("/path/to/file.txt")
content = state.load()

Common Operations

Chain transformations:

from iokit import Txt

state = Txt("Secret data", "notes")
encrypted = state.encrypt(password="secret")
compressed = encrypted.gzip()
compressed.save("/tmp")

Load compressed:

loaded = encrypted.load(password="secret").load()

Archives:

from iokit import Tar, Txt

file1 = Txt("First", "a")
file2 = Txt("Second", "b")

archive = Tar([file1, file2], "bundle")
states = list(archive.load())

Find states by pattern:

from iokit import filtrate, first

results = filtrate(archive.load(), "*.txt")
first_match = first(archive.load(), "a*")

Download:

from iokit import web

state = web("https://example.com/data.json", Json)
data = state.load()

Checksum:

state.digest("sha256").base64
state.digest("xxh128").base64url

Payloads of your own, filed under a format that knows nothing of them:

from dataclasses import dataclass
from typing import Any

from iokit import Json


@dataclass
class Person:
    name: str
    age: int


class PersonJson(Json[Person]):
    def dump(self, data: Person) -> dict[str, Any]:
        return {"name": data.name, "age": data.age}

    def parse(self, data: dict[str, Any]) -> Person:
        return Person(data["name"], data["age"])


state = PersonJson(Person("Joe", 32), "joe")
print(state.path)    # joe.json
print(state.load())  # Person(name='Joe', age=32)

The file stays an ordinary joe.json, and state.load() is a Person both at runtime and for the type checker. Every format takes the same pair: Txt, Csv, Npy, and the rest.

Storage

Store and retrieve records by uid:

from iokit.storage import LocalStorage

storage = LocalStorage("/data")
storage.push("records/data.json", data)

loaded = storage.pull("records/data.json")
storage.remove("records/data.json")

for uid in storage.index(prefix="records/"):
    print(uid)

State-aware storage with automatic encoding:

from iokit.storage import StateStorage

storage = StateStorage(
    LocalStorage("/data"),
    compression=6,
    password="secret"
)

storage.push("file.json", {"data": 123})
result = storage.pull("file.json")

Contributing

Found a bug or have an idea? Open an issue or submit a pull request.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

iokit-0.5.1.tar.gz (37.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

iokit-0.5.1-py3-none-any.whl (53.0 kB view details)

Uploaded Python 3

File details

Details for the file iokit-0.5.1.tar.gz.

File metadata

  • Download URL: iokit-0.5.1.tar.gz
  • Upload date:
  • Size: 37.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for iokit-0.5.1.tar.gz
Algorithm Hash digest
SHA256 5afe696d357d604fefc2419ae489fe47f7deb3be68ea9e21268cd734e6324694
MD5 7d6aaafde7ee34a5b17e7c185915fb70
BLAKE2b-256 bcdfa072141cbad9eef19ce6800583ff00ec5e13eee091c158f869b8e4db2dd4

See more details on using hashes here.

Provenance

The following attestation bundles were made for iokit-0.5.1.tar.gz:

Publisher: publish.yml on rilshok/iokit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file iokit-0.5.1-py3-none-any.whl.

File metadata

  • Download URL: iokit-0.5.1-py3-none-any.whl
  • Upload date:
  • Size: 53.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for iokit-0.5.1-py3-none-any.whl
Algorithm Hash digest
SHA256 89588d2f14c5162a8d54e9c2bef76e2637045b299f87ccec6bfa382fe0541070
MD5 e0141d98922136110d7365a33bd2d697
BLAKE2b-256 c6adc75e946092405813ed0e017a82dd69d4b2b46f54689ccccd3e05d98d7f80

See more details on using hashes here.

Provenance

The following attestation bundles were made for iokit-0.5.1-py3-none-any.whl:

Publisher: publish.yml on rilshok/iokit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.5.2

2 files

This release

0.5.1 This release

2 files

0.5.0

2 files

0.4.3

2 files

0.4.2

2 files

0.4.1

2 files

0.4.0

2 files

0.3.4

2 files

0.3.3

2 files

0.3.2

2 files

0.3.1

2 files

0.3.0

2 files

0.2.0

2 files

0.1.9

2 files

0.1.8

2 files

0.1.7

2 files

0.1.6

2 files

0.1.5

2 files

0.1.4

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 files

0.0.1

2 files

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