Wrap raw binary to class
Project description
raw-wrapper
A library for simple wrapping raw bytes to a class ✌️
Install
pip install raw-wrapper
Use
from dataclasses import dataclass
from raw_wrapper import RawWrapper
@dataclass
class SampleClass(RawWrapper):
"""Sample class"""
sample_4b_int: int = 0
sample_string: str = b''.ljust(12)
@staticmethod
def get_format():
return '>i12s'
@staticmethod
def expected_size():
return 16
data = b'\x00\x00\x00\x01Hello world!'
sample_class = SampleClass.wrap(data)
assert sample_class.sample_4b_int == 1
assert sample_class.sample_string == b'Hello world!'
Dev
More about format see https://docs.python.org/3/library/struct.html#format-characters
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 Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
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 raw_wrapper-1.0.0-py3-none-any.whl.
File metadata
- Download URL: raw_wrapper-1.0.0-py3-none-any.whl
- Upload date:
- Size: 3.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a981fccdb236c34b16d078d19199dab9ad6a79f69bb5e4a705242786856eed64
|
|
| MD5 |
657fcf4054f73a1692f6c74673d9f9f0
|
|
| BLAKE2b-256 |
47b244ef5f7e49419a5e292be10e61fc3126564b43c5986e0cf9719092452956
|