supyr-struct


Namesupyr-struct JSON
Version 1.5.4 PyPI version JSON
download
home_pagehttps://github.com/Sigmmma/supyr_struct
SummaryA versatile and extensible binary data parsing/serializing library for Python 3
upload_time2020-10-31 22:27:00
maintainer
docs_urlNone
authorSigmmma
requires_python>=3.5
licenseMIT
keywords supyr_struct binary data structure parser serializer serialize
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Supyr Struct

[![](https://img.shields.io/pypi/dm/supyr_struct)](https://pypistats.org/packages/supyr_struct)
![](https://ci.appveyor.com/api/projects/status/github/Sigmmma/supyr_struct?svg=true)
[![PyPI version](https://badge.fury.io/py/supyr-struct.svg)](https://pypi.org/project/supyr_struct/)
[![GitHub version](https://badge.fury.io/gh/Sigmmma%2Fsupyr_struct.svg)](https://github.com/Sigmmma/supyr_struct)

Supyr Struct is an extensible and powerful binary data parsing, editing, and serializing library for Python 3.

Supyr's parsing and serializing is declarative, meaning that rather than write code to handle parsing and serializing data, you instead create a description of the structure using various FieldTypes. These descriptions are used by BlockDef objects to build Blocks, which represent/contain the parsed data. A BlockDef is simply a constructor object that scans its description for errors on initialization and uses it for creating Blocks.


Supyr provides a large collection of FieldTypes, ranging from atomic data types(floats and ints of various sizes) to hierarchical structures(structs, containers, and arrays) and logical structures and wrappers(switches and unions).


For a detailed overview of the more abstract concepts and features of Supyr, read the text files in the 'docs' folder.

## Changelog
Check out the changelog [here](https://github.com/Sigmmma/supyr_struct/blob/master/CHANGELOG.MD).

## License
This project is licensed under the MIT License, check out the details and author info [here](https://github.com/Sigmmma/supyr_struct/blob/master/LICENSE.TXT).

## Installing

You'll need Python 3.5 or higher.

In your terminal execute:
```sh
python3 -m pip install supyr_struct
```
or, you can clone/download this repo and run the setup.py:
```sh
git clone git@github.com:Sigmmma/supyr_struct.git
cd supyr_struct
python3 -m pip install .
```


## Examples

Heres a small example of defining a structure using a BlockDef and FieldTypes and using it to create a Block.

```py

>>> from supyr_struct import *
>>>
>>>
>>> asdf = BlockDef('some_block',
... UInt32('some_int'),
... BytesRaw('some_bytes', SIZE=16),
... ENDIAN='>')
>>>
>>>
>>> test_block = asdf.build()
>>> test_block.some_int = 1337
>>> test_block['some_bytes'] = b'here\'s a cstring\x00'
>>>
>>> print('test_block:', test_block)
test_block: [ Container, entries:2, some_block
    [ UInt32, size:4, some_int, 1337 ]
    [ BytesRaw, size:16, some_bytes, <RAWDATA> ]
    ]
>>>
>>>
>>> test_block.serialize()
BytearrayBuffer(b"\x00\x00\x059here\'s a cstring\x00")
```

Supyr allows forcing endianness to be either big, little, or back to normal on a library scale and/or on individual FieldTypes.
```py
>>> field_types.FieldType.force_little()
>>> test_block.serialize()
BytearrayBuffer(b"9\x05\x00\x00here\'s a cstring\x00")
>>>
>>> field_types.FieldType.force_normal()
>>> test_block.serialize()
BytearrayBuffer(b"\x00\x00\x059here\'s a cstring\x00")
>>>
>>> field_types.FieldType.force_big()
>>> test_block.serialize()
BytearrayBuffer(b"\x00\x00\x059here\'s a cstring\x00")
>>>
>>> field_types.FieldType.force_little()
>>> test_block.serialize()
BytearrayBuffer(b"9\x05\x00\x00here\'s a cstring\x00")
```


Take a look at the examples module for some ready-to-run example programs that utilize Supyr in different ways.


## Who do I talk to?

If you're having any issues with the library you can report them on our [GitHub Issues page](https://github.com/Sigmmma/supyr_struct/issues).

If the issue requires some more direct attention we'll drop a contact link.



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/Sigmmma/supyr_struct",
    "name": "supyr-struct",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.5",
    "maintainer_email": "",
    "keywords": "supyr_struct,binary,data structure,parser,serializer,serialize",
    "author": "Sigmmma",
    "author_email": "MosesBobadilla@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/4a/f7/01ea8e64dbd90b7f433b112929d7295442c5843f6213fb1abfc1e386cf75/supyr_struct-1.5.4.tar.gz",
    "platform": "POSIX",
    "description": "# Supyr Struct\n\n[![](https://img.shields.io/pypi/dm/supyr_struct)](https://pypistats.org/packages/supyr_struct)\n![](https://ci.appveyor.com/api/projects/status/github/Sigmmma/supyr_struct?svg=true)\n[![PyPI version](https://badge.fury.io/py/supyr-struct.svg)](https://pypi.org/project/supyr_struct/)\n[![GitHub version](https://badge.fury.io/gh/Sigmmma%2Fsupyr_struct.svg)](https://github.com/Sigmmma/supyr_struct)\n\nSupyr Struct is an extensible and powerful binary data parsing, editing, and serializing library for Python 3.\n\nSupyr's parsing and serializing is declarative, meaning that rather than write code to handle parsing and serializing data, you instead create a description of the structure using various FieldTypes. These descriptions are used by BlockDef objects to build Blocks, which represent/contain the parsed data. A BlockDef is simply a constructor object that scans its description for errors on initialization and uses it for creating Blocks.\n\n\nSupyr provides a large collection of FieldTypes, ranging from atomic data types(floats and ints of various sizes) to hierarchical structures(structs, containers, and arrays) and logical structures and wrappers(switches and unions).\n\n\nFor a detailed overview of the more abstract concepts and features of Supyr, read the text files in the 'docs' folder.\n\n## Changelog\nCheck out the changelog [here](https://github.com/Sigmmma/supyr_struct/blob/master/CHANGELOG.MD).\n\n## License\nThis project is licensed under the MIT License, check out the details and author info [here](https://github.com/Sigmmma/supyr_struct/blob/master/LICENSE.TXT).\n\n## Installing\n\nYou'll need Python 3.5 or higher.\n\nIn your terminal execute:\n```sh\npython3 -m pip install supyr_struct\n```\nor, you can clone/download this repo and run the setup.py:\n```sh\ngit clone git@github.com:Sigmmma/supyr_struct.git\ncd supyr_struct\npython3 -m pip install .\n```\n\n\n## Examples\n\nHeres a small example of defining a structure using a BlockDef and FieldTypes and using it to create a Block.\n\n```py\n\n>>> from supyr_struct import *\n>>>\n>>>\n>>> asdf = BlockDef('some_block',\n... UInt32('some_int'),\n... BytesRaw('some_bytes', SIZE=16),\n... ENDIAN='>')\n>>>\n>>>\n>>> test_block = asdf.build()\n>>> test_block.some_int = 1337\n>>> test_block['some_bytes'] = b'here\\'s a cstring\\x00'\n>>>\n>>> print('test_block:', test_block)\ntest_block: [ Container, entries:2, some_block\n    [ UInt32, size:4, some_int, 1337 ]\n    [ BytesRaw, size:16, some_bytes, <RAWDATA> ]\n    ]\n>>>\n>>>\n>>> test_block.serialize()\nBytearrayBuffer(b\"\\x00\\x00\\x059here\\'s a cstring\\x00\")\n```\n\nSupyr allows forcing endianness to be either big, little, or back to normal on a library scale and/or on individual FieldTypes.\n```py\n>>> field_types.FieldType.force_little()\n>>> test_block.serialize()\nBytearrayBuffer(b\"9\\x05\\x00\\x00here\\'s a cstring\\x00\")\n>>>\n>>> field_types.FieldType.force_normal()\n>>> test_block.serialize()\nBytearrayBuffer(b\"\\x00\\x00\\x059here\\'s a cstring\\x00\")\n>>>\n>>> field_types.FieldType.force_big()\n>>> test_block.serialize()\nBytearrayBuffer(b\"\\x00\\x00\\x059here\\'s a cstring\\x00\")\n>>>\n>>> field_types.FieldType.force_little()\n>>> test_block.serialize()\nBytearrayBuffer(b\"9\\x05\\x00\\x00here\\'s a cstring\\x00\")\n```\n\n\nTake a look at the examples module for some ready-to-run example programs that utilize Supyr in different ways.\n\n\n## Who do I talk to?\n\nIf you're having any issues with the library you can report them on our [GitHub Issues page](https://github.com/Sigmmma/supyr_struct/issues).\n\nIf the issue requires some more direct attention we'll drop a contact link.\n\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A versatile and extensible binary data parsing/serializing library for Python 3",
    "version": "1.5.4",
    "split_keywords": [
        "supyr_struct",
        "binary",
        "data structure",
        "parser",
        "serializer",
        "serialize"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "db537ec5d260832d73ffcc99a7db707e96d78aa09c80324be47d9da5657d521e",
                "md5": "5b76cf6913ee49f014df977d57613e22",
                "sha256": "cf027a860ee364584d5cdb29c7ca58a14d3763e8805dc427b4f346ef58cc147d"
            },
            "downloads": -1,
            "filename": "supyr_struct-1.5.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "5b76cf6913ee49f014df977d57613e22",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.5",
            "size": 236476,
            "upload_time": "2020-10-31T22:26:58",
            "upload_time_iso_8601": "2020-10-31T22:26:58.857900Z",
            "url": "https://files.pythonhosted.org/packages/db/53/7ec5d260832d73ffcc99a7db707e96d78aa09c80324be47d9da5657d521e/supyr_struct-1.5.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4af701ea8e64dbd90b7f433b112929d7295442c5843f6213fb1abfc1e386cf75",
                "md5": "ba01c3b2b9e517251386870d83e2ef84",
                "sha256": "6ea341739d78b99dc18cccc02e659f9db12d5700e0c2cee4426b67b0684faea9"
            },
            "downloads": -1,
            "filename": "supyr_struct-1.5.4.tar.gz",
            "has_sig": false,
            "md5_digest": "ba01c3b2b9e517251386870d83e2ef84",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.5",
            "size": 197492,
            "upload_time": "2020-10-31T22:27:00",
            "upload_time_iso_8601": "2020-10-31T22:27:00.393306Z",
            "url": "https://files.pythonhosted.org/packages/4a/f7/01ea8e64dbd90b7f433b112929d7295442c5843f6213fb1abfc1e386cf75/supyr_struct-1.5.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2020-10-31 22:27:00",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "Sigmmma",
    "github_project": "supyr_struct",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "appveyor": true,
    "lcname": "supyr-struct"
}
        
Elapsed time: 0.04571s