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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file iokit-0.1.9.tar.gz
.
File metadata
- Download URL: iokit-0.1.9.tar.gz
- Upload date:
- Size: 13.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 25bf52df117d23721345da58930ef2c8f12d5adb927c38d3b9782e4801098cdb |
|
MD5 | 1ee36fcf0b3c72d40b4b0b973ae60a44 |
|
BLAKE2b-256 | 437f2535927e8accbeecca18d27da87815517c00d58e88781194625865526919 |
File details
Details for the file iokit-0.1.9-py3-none-any.whl
.
File metadata
- Download URL: iokit-0.1.9-py3-none-any.whl
- Upload date:
- Size: 13.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 96a9c8bd474d4067b36f850b96b798500121a05fd57e117afa060ccf937a6eaa |
|
MD5 | bdf45ccbe2f43c83b2b33f4794c0b488 |
|
BLAKE2b-256 | f844a91c71108b108d8ea13b0ec77d6880b553867c4443f95e8c922f8d10ad56 |