Binfmt is a binary exchange format
Permuatio uses a binary format called binformat. This is a python implementation of said format.
Usage
The module exports main 2 methods write_msg and read_msg, as well as their safe (non-exception throwing) counterparts safe_write_msg and safe_read_msg.
Documentation:
write_msg
Takes 2 argumentss
file: a BufferedWriter that can have binary values write toobj: one of the types that binformat can represent, that will be writen
safe_write_msg
Takes 2 argument:
filename: a filename that the file should be written to, should there not be issues with writing the valueobj: as in above
It also returns 1 value: Either None or str which is an error string
read_msg
Takes 1 argument:
file: a BufferedReader that can have binary values read from
It also returns 1 value: an object that has been read from the file.
safe_read_msg
Takes 1 argument:
filename: a filename that the file should be read from
It also returns 1 value: an object that has been read from the file or an error.
Example
import binformat
safe_write_msg("hexxy", {
1: b"Hello world",
2: [1, 2, 3]
})
with open("hexxy", "rb") as f:
print(read_msg(f))
# { 1: b"Hello world", 2: [1, 2, 3] }
Testing
Run tests.py
Release files for binformat 1.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| binformat-1.0.2.tar.gz | 14.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| binformat-1.0.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 29.7 kB
Release files / binformat-1.0.2.tar.gz
| Download URL | binformat-1.0.2.tar.gz |
|---|---|
| Size | 14.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3d40960be0e8471a2d33808769a6dcae0103d33f3e648f2dbd0b1e3d692fba77
|
|
BLAKE2b-256 checksum How to use checksums |
b6089ada7f81e1f41b2bffd632a8fb695efab72c15f9b5bee5351290cf8fb677
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.13 CPython/3.10.9 Darwin/22.2.0
|
Release files / binformat-1.0.2-py3-none-any.whl
| Download URL | binformat-1.0.2-py3-none-any.whl |
|---|---|
| Size | 14.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
26d04e144a77fa33f9b177bec56457dbce6567fabc3e45d204c6fa1e525f2919
|
|
BLAKE2b-256 checksum How to use checksums |
c52765fdb63f7df0a6ff35b2615b718c0b0743c4807be358a5d300fdaaf10649
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.13 CPython/3.10.9 Darwin/22.2.0
|