Skip to main content

Domain Specific Language(DSL) for parsing and mapping binary data to python objects

Project description

Python package for mapping objects to binary data. It works with Python 2.7+


Binmapper is available from and can be installed using pip

pip install binmapper

Example usage

import binmapper
import textwrap

definition = u"""\
    bintype BinX:
        field: uint8
    bintype Bin:
        fieldX: BinX
definition = textwrap.dedent(definition)
binmap = binmapper.compile(definition)
bin = binmap.Bin()
input = io.BytesIO("\x01")

Data types

Type Byte Size Description
uint8 1 Unsigned byte
uint16 2 Unsigned short
uint32 4 Unsigned short
sint8 1 Signed byte
sint16 2 Signed short
sint32 4 Signed word
float 4 Floating point with single-precision
string n String
array n Array

Common class template

bintype CLASS_NAME:



Value Description
littlendian Increasing numeric significance with increasing memory addresses
bigendian Decreasing numeric significance with increasing memory addresses

Byteorder can be specified 3-way

  • Field attribute

    field: uint8 &byteorder=littlendian

    Apply only to field

  • BinType attribute

    field: uint8

    Apply to all fields in BinType, except having attribute byteorder

  • Parse argument

    bin.parse(input, byteorder='littlendian')

    Apply to all parsed data, except having attribute byteorder or BinType byteorder

Byteorder apply order:

`field byteorder > class byteorder > parse byteorder`

Class Usage

Array Usage

String Usage

Let Field Usage

Change elements in runtime

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for binmapper, version 0.1a5
Filename, size File type Python version Upload date Hashes
Filename, size (50.5 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page