Dumpy
Dumpy is a binary parser with a declarative syntax. All you need to do is telling the framework what your data look like, and let Dumpy do the rest.
Dumpy supports python versions >= 3.0.
Installing
Just use pip or tools alike:
pip install dumpy
Usage
To parse a pre-defined binary structure, you need to define a class for that structure. For example, a class for pascal strings :
import dumpy.types as dt
class PString(dict, metaclass=dt.DumpyMeta):
__field_specs__ = (
dt.field('len', dt.UInt8, default=dt.count_of('data')),
dt.field('data', dt.UInt8, count=dt.counted_by('len')),
)
s = PString()
s['data'] = b'\x01\x02\x03\x04'
# The length field is calculated automatically.
assert s['len'] == 4
assert s.pack() == b'\x04\x01\x02\x03\x04'
s2 = s.unpack(s.pack())
assert s2['len'] == 4
assert bytes(s2['data']) == b'\x01\x02\x03\x04'
See demo/png_packer.py for a real-world format parser.
Known Issues
The type checking and conversion code in Dumpy is kind of naive, It does not check element types in a sequence.
Dumpy is very slow at current stage. You may not want to use it to parse network messages or huge data structures.
Metadata
Release files for dumpy 0.1.2
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 | |
|---|---|---|---|---|
| dumpy-0.1.2.tar.gz | 7.5 kB | Without provenance | Details |
Release files / dumpy-0.1.2.tar.gz
| Download URL | dumpy-0.1.2.tar.gz |
|---|---|
| Size | 7.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
598f8dae01b1c49c457fd96941cee315f5dc734a78a86ce048511ecd3a2e89f5
|
|
BLAKE2b-256 checksum How to use checksums |
2afbb78893e906a0e67dd2cf7cfd46e04ad8946778ceb426bd3c9583ab34a162
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for dumpy 0.1.2
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.