{ "info": { "author": "Joshua Skelton", "author_email": "joshua.skelton@gmail.com", "bugtrack_url": null, "classifiers": [ "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 3", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "# [![wick](https://raw.githubusercontent.com/joshuaskelly/wick/master/.media/logo.svg?sanitize=true)](https://github.com/JoshuaSkelly/wick)\n\n# wick\n\n[![Python 3.6](https://img.shields.io/badge/python-3.6-blue.svg)]() [![PyPI version](https://badge.fury.io/py/wick.svg)](https://pypi.python.org/pypi/wick) [![Build Status](https://travis-ci.org/joshuaskelly/twitch-observer.svg?branch=master)](https://travis-ci.org/joshuaskelly/twitch-observer)\n\nwick is a Python command line tool that automatically generates file I/O source code for working with binary data.\n\n## Why?\nI was working on a project that involved reverse engineering file formats and I found that most data structures tend to be composed of several simpler data structures. I also noticed that the simpler structures were all very boilerplate. So I created this tool to write the simple structures for me, and I can do the more interesting work of composing them into the larger structure.\n\n## Supported Target Languages\n- C#\n- JavaScript\n- Python\n\n## Installation\n\n```shell\n$ pip install wick\n```\n\n## Usage\n\n```shell\n$ wick example.h Python\n```\n\n## What _exactly_ does it do?\n\nLet's walk through a concrete example.\n\nSay we have binary data that is a sequence of records that are represented by a string name and an integer id. First we create a record.h file that contains a C struct representation of this data:\n\n```C\n// record.h\n\n// Simple Record\nstruct Record {\n // Record name\n char name[64];\n\n // Record id.\n unsigned char id;\n};\n```\n\nThen we run `wick` on the file:\n\n```shell\n$ wick record.h Python\n```\n\nWhich will then create a record.py file whose contents look like:\n\n```python\n# record.py\nimport struct\n\n\nclass Record:\n \"\"\"Simple Record object\n\n Attributes:\n name: Record name\n\n id: Record id.\n \"\"\"\n\n format = '<64sB'\n size = struct.calcsize(format)\n\n __slots__ = (\n 'name',\n 'id'\n )\n\n def __init__(self,\n name,\n id):\n self.name = name.split(b'\\x00')[0].decode('ascii') if type(name) is bytes else name\n self.id = id\n\n @classmethod\n def write(cls, file, record):\n record_data = struct.pack(cls.format,\n record.name.encode('ascii'),\n record.id)\n\n file.write(record_data)\n\n @classmethod\n def read(cls, file):\n record_data = file.read(cls.size)\n record_struct = struct.unpack(cls.format, record_data)\n\n return Record(*record_struct)\n\n```\n\nThen we can import this code into Python and _do work_.\n\n### Read Data\n```python\nwith open(path, 'rb') as file:\n rec = Record.read(file)\n```\n\n### Write Data\n```python\nwith open(path, 'wb') as file:\n rec = Record(b'name', 0)\n Record.write(file, rec)\n```\n\n### Unpack Lots of Data\n```python\nimport struct\n\n# Assuming the file only contains Record data\nwith open(path, 'rb') as file:\n recs = [Record(*chunk) for chunk in struct.iter_unpack(Record.format, file.read())]\n```\n\n## Contributing\nHave a bug fix or a new feature you'd like to see in wick? Send it our way! Please make sure you create an issue that addresses your fix/feature so we can discuss the contribution.\n\n1. Fork this repo!\n2. Create your feature branch: `git checkout -b features/add-javascript-code-generator`\n3. Commit your changes: `git commit -m 'Implemented Javascript code generator'`\n4. Push the branch: `git push origin add-javascript-code-generator`\n5. Submit a pull request.\n6. Create an [issue](https://github.com/joshuaskelly/wick/issues/new).\n\n## License\nMIT\n\nSee the [license](./LICENSE) document for the full text.", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/JoshuaSkelly/wick", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "wick", "package_url": "https://pypi.org/project/wick/", "platform": "", "project_url": "https://pypi.org/project/wick/", "project_urls": { "Homepage": "https://github.com/JoshuaSkelly/wick" }, "release_url": "https://pypi.org/project/wick/1.1.0/", "requires_dist": null, "requires_python": "", "summary": "", "version": "1.1.0" }, "last_serial": 4207569, "releases": { "0.6.1": [ { "comment_text": "", "digests": { "md5": "71bf2ff62e6d80327bdd43e5ade04a60", "sha256": "8b88a8b84595586296c4b9c3b84044050bb0548273451509ac0148890a7284ab" }, "downloads": -1, "filename": "wick-0.6.1.tar.gz", "has_sig": false, "md5_digest": "71bf2ff62e6d80327bdd43e5ade04a60", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 15218, "upload_time": "2018-08-21T19:49:56", "url": "https://files.pythonhosted.org/packages/ba/6e/f4d3d25e3491a4df03b6cef9ee66036bf76ab21443ab0e7f9d2f227d9859/wick-0.6.1.tar.gz" } ], "0.6.2": [ { "comment_text": "", "digests": { "md5": "e9945c2ac260a7bdff38e14b6c1ea92d", "sha256": "23020630a21858639916c4aa3777813541a3c80a23b35761657b617f5f3e1d8d" }, "downloads": -1, "filename": "wick-0.6.2.tar.gz", "has_sig": false, "md5_digest": "e9945c2ac260a7bdff38e14b6c1ea92d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 15281, "upload_time": "2018-08-21T19:56:57", "url": "https://files.pythonhosted.org/packages/db/66/f20baf241c6388d762922bb465415d84a85fd58fdcc0277b8180f57ab58e/wick-0.6.2.tar.gz" } ], "0.6.3": [ { "comment_text": "", "digests": { "md5": "b8f24313db536d5d7274a54d09ccb5a6", "sha256": "41ab32e6ffb62ede7dbea25a6d62298bcfa95cb260f221553dbb3ae42421f92b" }, "downloads": -1, "filename": "wick-0.6.3.tar.gz", "has_sig": false, "md5_digest": "b8f24313db536d5d7274a54d09ccb5a6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 15278, "upload_time": "2018-08-21T20:06:05", "url": "https://files.pythonhosted.org/packages/1c/c7/9c3f9e47ddea4d6eb9aaf6d6e5769fbe3bf05c6210c47e3379a1624474d1/wick-0.6.3.tar.gz" } ], "0.6.4": [ { "comment_text": "", "digests": { "md5": "8339b5b22a1217f93e502a95384b1c51", "sha256": "10920826add4815c4de4e9f66edd3c276cf59f99d12cace7932b64ef914f1957" }, "downloads": -1, "filename": "wick-0.6.4.tar.gz", "has_sig": false, "md5_digest": "8339b5b22a1217f93e502a95384b1c51", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 15344, "upload_time": "2018-08-21T20:29:20", "url": "https://files.pythonhosted.org/packages/2a/c4/0e979d71d41f3f89904f037f016a4bd436f8585817f7cdca6a2010285de0/wick-0.6.4.tar.gz" } ], "1.0.0": [ { "comment_text": "", "digests": { "md5": "ad37816df8f54c0cd3e17649ee91d1e2", "sha256": "fe4773baee9535b9480122b2f3f1055764be2578086c84c85c9f7a611553796a" }, "downloads": -1, "filename": "wick-1.0.0.tar.gz", "has_sig": false, "md5_digest": "ad37816df8f54c0cd3e17649ee91d1e2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 17854, "upload_time": "2018-08-23T21:08:19", "url": "https://files.pythonhosted.org/packages/7c/db/11fddda79cc7042b20d7be30106ba48d1f122f9fa39c87bb2cf059024e83/wick-1.0.0.tar.gz" } ], "1.0.1": [ { "comment_text": "", "digests": { "md5": "aca35311625b30cb272565ddc79b92c8", "sha256": "983f8f0afd1beaae8a9e71d38614e9b7d164a4ea8c27ba1910eaa8521502f912" }, "downloads": -1, "filename": "wick-1.0.1.tar.gz", "has_sig": false, "md5_digest": "aca35311625b30cb272565ddc79b92c8", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 18279, "upload_time": "2018-08-24T03:29:55", "url": "https://files.pythonhosted.org/packages/68/d0/2c138b689724be4d8dbf346230543a26feaca5e0a556edf2e98d46bbc649/wick-1.0.1.tar.gz" } ], "1.1.0": [ { "comment_text": "", "digests": { "md5": "be4af7d9e7541703c0372dbece4e2e52", "sha256": "17e1616947a0b4c68311d85909ed2b62f24bd6ec6367a985df34fa9db94ce0f9" }, "downloads": -1, "filename": "wick-1.1.0.tar.gz", "has_sig": false, "md5_digest": "be4af7d9e7541703c0372dbece4e2e52", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 19551, "upload_time": "2018-08-26T03:48:30", "url": "https://files.pythonhosted.org/packages/ef/99/53bc63b4300e61f28115b4db7b53558436ec629c8aba8ee8d45966d7a4f2/wick-1.1.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "be4af7d9e7541703c0372dbece4e2e52", "sha256": "17e1616947a0b4c68311d85909ed2b62f24bd6ec6367a985df34fa9db94ce0f9" }, "downloads": -1, "filename": "wick-1.1.0.tar.gz", "has_sig": false, "md5_digest": "be4af7d9e7541703c0372dbece4e2e52", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 19551, "upload_time": "2018-08-26T03:48:30", "url": "https://files.pythonhosted.org/packages/ef/99/53bc63b4300e61f28115b4db7b53558436ec629c8aba8ee8d45966d7a4f2/wick-1.1.0.tar.gz" } ] }