Writema? What's Writema?
Project description
Writema? What's Writema?
Writema is a binary stream writing library
Well, what does it do?
Well I'm glad you asked!
Writema is a little library I started to help with writing 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 writing ability?
Cool Badges
Usage
Note, requires Python 3.8 or higher (For now at least)
Installation
pip install writema
Sample code
from writema import Writema
# Let's say you want to write a file to contain in order:
# - An integer
# - An unsigned integer
# - A double
# - A string prefixed by its length with a byte
# - A large buffer blob you dont exactly know the length of
w = Writema("some_file.bin") # note: defaults to Little Endian
w.write(4, 69) # write a 4 byte integer (int32_t)
w.uwrite(2, -1337) # write an unsigned 2 bit integer (uint16_t)
w.write("d", 2.718281828459045) # write the constant e as a double
string = b"Hello, World!"
length = len(string)
w.write(1, length)
w.bytes(string)
important_data = ... # imagine theres some very large binary blob here in bytes
w.bytes(important_data)
Example of ways to do the same action
from writema import Writema, WritemaTypes
w = Writema()
# lets say you want the end buffer to be b"AAAABBBBCCCCDDDD"
# heres four ways you can do each of the four bytes
w.write(4, 1094795585) # Writes a 32 bit (4 byte) integer (AAAA = 1094795585)
w.write("int", 1111638594) # this also writes a 32 bit int (BBBB = 1111638594)
w.write(WritemaTypes.int, 1128481603) # someone might prefer this idk (CCCC = 1128481603)
w.bytes(b"DDDD") # its a bytestring, probably the easiest to work with
Other examples
# writing floats and doubles is a little scuffed for now, i plan to find a better solution
w.write("f", 6.9)
w.write("float", 6.9)
w.write(WritemaTypes.float, 6.9)
w.write("d", 6.90000001)
w.write("double", 6.90000001)
w.write(WritemaTypes.double, 6.90000001)
# you can also set endianness
w.set_endianness("big")
# and
w.set_endianness("little") # the correct endianness /s
Documentation
tba
License
Copyright (c) 2022 whamer100
This project is MIT licensed.
hey is this project name just one big ligma joke
maybe
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file writema-1.0.1a0.tar.gz.
File metadata
- Download URL: writema-1.0.1a0.tar.gz
- Upload date:
- Size: 7.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a1486eb535d1ecf29a26146a69c9cbd1e976a340aa6376a9929cb2bf1f33c2fb
|
|
| MD5 |
c58107c4029c746fb991f1616c12a87b
|
|
| BLAKE2b-256 |
c089b65d6ae382c03daec5cdbf7cca37119371e23b1c8e5c7aff07e98293b53e
|
File details
Details for the file writema-1.0.1a0-py3-none-any.whl.
File metadata
- Download URL: writema-1.0.1a0-py3-none-any.whl
- Upload date:
- Size: 7.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
346a2d01a05a8beb5b00a2874b639bfdbe0014f512090bbe477d2c04fd5c5180
|
|
| MD5 |
6fe1d0a909dd77a6cdf540c69d85c940
|
|
| BLAKE2b-256 |
9ff4fbc21765c2c28664cf393a422134b21beab3b22c4cc33fcbec9c179f7999
|