https://github.com/romanin-rf/pychunker
Python module for reading/writing a chunk file.
https://github.com/romanin-rf/pychunker
chunk chunkfile file-like io python python3
Last synced: 10 months ago
JSON representation
Python module for reading/writing a chunk file.
- Host: GitHub
- URL: https://github.com/romanin-rf/pychunker
- Owner: romanin-rf
- License: mit
- Created: 2023-07-13T21:00:27.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-01-06T04:00:38.000Z (about 2 years ago)
- Last Synced: 2025-03-08T01:35:27.183Z (11 months ago)
- Topics: chunk, chunkfile, file-like, io, python, python3
- Language: Python
- Homepage: https://pypi.org/project/pychunker
- Size: 22.5 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Chunker
## Description
Module for reading/writing chunk files.
## Installation
```
pip install pychunker
```
## Using
- `example.py`:
```python
import pychunker
with pychunker.open("chunkfile.bin", "w") as cf:
# The chunk can be used via `with'.
with cf.chunk("DDAT") as ddat:
ddat.write(b'1234567890')
# Or by contacting the key (name of the chunk).
cf["SDAT"].write(b'Hello World!')
# !!! Attention !!!
# Both types of treatment use the same methods,
# namely that if you open a chunk file in read-only mode,
# and if the chunk is not in the chunk file,
# he will try to create a chunk,
# but he will not be able to do this and will give a `IONotWritableError`.
with pychunker.open("chunkfile.bin") as cf:
print(cf.chunks)
```
- `Output`:
```python
[Chunk(name='DDAT', mode='r', size=10), Chunk(name='SDAT', mode='r', size=12)]
```