MothPriest
Python module for creating intuitive file parsers.
Imagine you have a file with the following structure:
| Field | Size (Bytes) | Value |
|---|---|---|
| Magic | 6 | "STRING" |
| StringSize | 4 | uint32 (little endian) size String in bytes |
| String | StringSize | string data for this file |
MothPriest makes parsing and editing this file simple:
from io import BytesIO
from mothpriest.parsers import *
parser = BlockParser(
"root",
[
MagicParser("STRING", "Magic"),
IntegerParser("StringSize", size=4, little_endian=True, signed=False),
StringParser("String", size="StringSize") # Note the reference back to StringSize
]
)
data = b"STRING\x1A\x00\x00\x00Lorem ipsum dolor sit amet"
with BytesIO(data) as buffer:
parser(buffer)
assert parser['String'] == "Lorem ipsum dolor sit amet"
parser['String'] = "The quick brown fox jumps over the lazy dog"
# StringSize is now inconsistent with String, but there is no need to manually update
with BytesIO() as buffer:
parser.unparse(buffer)
buffer.seek(0)
output_data = buffer.read()
# Note how StringSize is updated automatically
assert output_data == b"STRING\x2B\x00\x00\x00The quick brown fox jumps over the lazy dog"
Metadata
Release files for MothPriest 1.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| mothpriest-1.1.0.tar.gz | 13.9 kB | Without provenance | Details for mothpriest-1.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| mothpriest-1.1.0-py3-none-any.whl | Python 3 | none | any | Details for mothpriest-1.1.0-py3-none-any.whl |
Total release size: 29.0 kB
Release files / mothpriest-1.1.0.tar.gz
| Download URL | mothpriest-1.1.0.tar.gz |
|---|---|
| Size | 13.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ffc0907a5add4a27b3c60c09cf5c6b384c06510b182c8ee91d4ce624a76d74e4
|
|
BLAKE2b-256 checksum How to use checksums |
e618e6c02d83f3d460d57b2f83bb21fc418505c27d3f0e67c8753cb939aa29da
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.11.11
|
Release files / mothpriest-1.1.0-py3-none-any.whl
| Download URL | mothpriest-1.1.0-py3-none-any.whl |
|---|---|
| Size | 15.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
aa6394b0ff25d550622088f5b912f2e272c80860c5eea33a88bc9d8e8dbdf17a
|
|
BLAKE2b-256 checksum How to use checksums |
57bf679a669f7107413483c64557affede852e480c19becfcf08fec4ecb0e9b8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.11.11
|
Security for MothPriest 1.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.