Skip to main content

Input Output Kit

Project description

I/O Kit Python Library

IOKit is a Python library that offers a suite of utilities for managing a wide range of input/output operations. Central to its design is the concept of a State, where each state signifies a unit of data that can be loaded, saved, or transformed. Each state corresponds to a valid file state, represented as a bytes-like object.

IOKit abstracts and unifies serialization and deserialization operations from various libraries into a single, cohesive interface. This allows for direct manipulation of the file's state in memory, eliminating the need for disk interaction. Consequently, it facilitates the (de)serialization of data in multiple formats, such as json, yaml, txt, tar, gzip, among others. This abstraction not only simplifies data handling but also enhances efficiency by reducing disk I/O operations.

Installation

You can install the IOkit library using pip:

pip install iokit

Usage

Here are some examples of how to use the I/O Kit library:

Text File Handling

from iokit import Txt

text = "Hello, World!"
state = Txt(text, name="text")
print(state)
print(state.load())
text.txt (13B)
Hello, World!

JSON

from iokit import Json

data = {"key": "value"}
state = Json(data, name="single")
print(state)
print(state.load())
single.json (16B)
{'key': 'value'}

YAML

from iokit import Yaml

data = {"key": "value"}
state = Yaml(data, name="single")
print(state)
print(state.load())
single.yaml (11B)
{'key': 'value'}

GZip Compression

from iokit import Txt, Gzip

data = "Hello, World! "* 1000
state = Gzip(Txt(data, name="data"))
print(state)
print(len(state.load().load()))
data.txt.gz (133B)
14000

Tar Archive

from iokit import Tar, Txt

state1 = Txt("First file", name="text1")
state2 = Txt("Second file", name="text2")
archive = Tar([state1, state2], name="archive")
states = archive.load()
print(states)
print(states[0].load())
print(states[1].load())
[text1.txt (10B), text2.txt (11B)]
First file
Second file

Find State

from iokit import Tar, find_state

state1 = Txt("First file", name="text1")
state2 = Txt("Second file", name="text2")
archive = Tar([state1, state2], name="archive")

state = find_state(archive.load(), "?e*2.txt")
print(state.load())
Second file

Byte input handling

from iokit import State

state = State(b"{\"first\": 1, \"second\": 2}", name="data.json")
print(state.load())
{'first': 1, 'second': 2}

Contributing

Contributions to the IOkit library are welcome. Please feel free to submit a pull request or open an issue on the GitHub repository.

License

The IOkit library is licensed under the MIT License. You can use it for commercial and non-commercial projects without any restrictions.

Project details


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.3.4.tar.gz (21.2 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.3.4-py3-none-any.whl (21.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: iokit-0.3.4.tar.gz
  • Upload date:
  • Size: 21.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for iokit-0.3.4.tar.gz
Algorithm Hash digest
SHA256 cc49841b309f3aa4512ad3b10848606d16a875f528d1a5f2374bc06721f5d949
MD5 9d291061fc6dad7dabcccf0b324ae928
BLAKE2b-256 c2e700e2cf9a9c98254a598b9fe4ef6afbef05c93ec127be4847255ede377bba

See more details on using hashes here.

Provenance

The following attestation bundles were made for iokit-0.3.4.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.3.4-py3-none-any.whl.

File metadata

  • Download URL: iokit-0.3.4-py3-none-any.whl
  • Upload date:
  • Size: 21.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for iokit-0.3.4-py3-none-any.whl
Algorithm Hash digest
SHA256 c8f8436551681a35440c2d147363b25d3ad4997acbfb7780fd29dd2d0dd187a3
MD5 18c9f22d507b06a7f1cb3a1ae6ed9308
BLAKE2b-256 8fc7488868456cc31a5b309ef0d27d55ed8d344bec3d438f7b35959c82efc962

See more details on using hashes here.

Provenance

The following attestation bundles were made for iokit-0.3.4-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.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page