Readma is a binary stream reading library I made for fun that I decided I would extend on and release
Well, what does it do?
Readma is a little library I started to help with parsing binary files.
That's it?
Well yeah, what did you expect? Some large module I've been writing my entire life that will change the world with its amazing binary reading ability?
Note, requires Python 3.8 or higher (For now at least)
pip install readma
from readma import Readma
# Let's say this file contains in order:
# - An integer
# - An unsigned integer
# - A float
# - A string prefixed by its length with a byte
# - An unknown amount of data you just really need read
r = Readma("some_file.bin") # note: defaults to Little Endian
integer = r.read(4) # size in bytes
unsigned_integer = r.uread(4)
a_float = r.float()
length = r.read(1)
string = r.bytes(length)
important_data = r.readall()
Example of ways to do the same action
from readma import Readma, ReadmaTypes
r = Readma(b"AAAABBBBCCCCDDDD")
A = r.read(4) # Reads a 32 bit (4 byte) integer
B = r.read("int") # this also reads a 32 bit int
C = r.read(ReadmaTypes.int) # someone might prefer this idk
D = r.bytes(4) # its a bytestring, do whatever with it
You can also move around the buffer using seek, skip, and tell
from readma import Readma
r = Readma(b"AAAABBCCCCXXXXXXXXDDDD")
A = r.read(4)
r.seek(6) # seek past B
C = r.read(4)
r.skip(8) # skip past the next 8 bytes
D = r.read(4)
Oh and you can check the size of the buffer too
from readma import Readma
r = Readma(b"AAAABBBBCCCCDDDD")
assert r.size() == 16
# observe the script not halting
Copyright (c) 2021 whamer100
This project is MIT licensed.
hey is this project name just one big ligma joke