Read/Write binary files after describing their specifications in code (similar to an ORM table schema)
Project description
BinaryFileParser
BinaryFileParser allows the user to create a binary file format specification in the form of a struct and then use it to read/write files.
Installation
On Linux:
$ python3 -m venv venv
$ source venv/bin/activate
$ pip install binary-file-parser
On Windows:
> py -m venv venv
> venv/Scripts/activate
> pip install binary-file-parser
Getting Started
This is a very basic script to give you an idea of how to use this library. Check out the API Reference (coming soon™) for documentation containing more details on how to use this library.
from binary_file_parser import BaseStruct, Retriever
from binary_file_parser.types import int32, uint64, str32, FixedLenStr
class Spam(BaseStruct):
file_version: str = Retriever(FixedLenStr[4], default = 0)
creator_name: str = Retriever(str32, default = 0)
saved_timestamp: int = Retriever(uint64, default = 0)
eggs: int = Retriever(int32, default = 0)
# read a binary file that has the above format
file = Spam.from_file("path/to/file")
# modify the creator name
file.creator_name = "Alian713"
file.eggs = 20
# write the modified data to a new file
file.to_file("path/to/write/to")
About the Author
If you have any questions, suggestions or feedback regarding the library, feel free to send me a message on discord!
Author | Discord |
---|---|
Alian713 | Alian713#0069 |
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
binary-file-parser-0.1.0.tar.gz
(16.0 kB
view hashes)
Built Distribution
Close
Hashes for binary_file_parser-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5f00902f047751e2de783dae9b10fad4402112862079a138be87519fdefcee74 |
|
MD5 | 345f1da7a41baea813f0d85d8a61be7f |
|
BLAKE2b-256 | ceaa26c8799f0e5b958a17bc44ed0d01af8d65c403edec789d02236938814d1d |