GithubHelp home page GithubHelp logo

readma's Introduction

Readma? What's Readma?

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?

Well I'm glad you asked!

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?

Cool Badges

Tests

Usage

Note, requires Python 3.8 or higher (For now at least)

Installation

pip install readma

Sample code

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

Documentation

License

Copyright (c) 2021 whamer100
This project is MIT licensed.


hey is this project name just one big ligma joke

maybe

readma's People

Contributors

whamer100 avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.