{ "info": { "author": "Almog Cohen", "author_email": "", "bugtrack_url": null, "classifiers": [ "Intended Audience :: Developers", "License :: OSI Approved :: Apache Software License", "Natural Language :: English", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6" ], "description": "===================\nProtoBuf Schematics\n===================\n\n\n.. image:: https://img.shields.io/pypi/v/protobuf_schematics.svg\n :target: https://pypi.python.org/pypi/protobuf_schematics\n\n.. image:: https://img.shields.io/travis/AlmogCohen/protobuf-schematics.svg\n :target: https://travis-ci.org/AlmogCohen/protobuf-schematics\n\n.. image:: https://readthedocs.org/projects/protobuf-schematics/badge/?version=latest\n :target: https://protobuf-schematics.readthedocs.io/en/latest/?badge=latest\n :alt: Documentation Status\n\n\nConvert ProtoBuf ``proto`` file to cute Schematics_ classes file.\n\nGoogle Protobuf is great when it comes to high performance schema aware APIs, but when Google designed Protobuf, it didn't tried to make the generated code idiomatic in Python, which brings a problem when exporting messages outside interface modules or having nice IDE auto-completions. Schematics is a cute and Pythonic schema library that goes well with most applications. Why not join both?\n\nCurrently this package does **not** support the Protobuf binary format and will work with a any other textual representation which is easily generated with the original Protobuf API for any language. Ease of use was prioritized while writing this package rather than mere performance.\n\n\n* Free software: Apache Software License 2.0\n* Documentation: https://protobuf-schematics.readthedocs.io.\n\n\n.. _Schematics: https://github.com/schematics/schematics\n\nUsage\n-----\n\n1. Convert the ``proto`` file to python Schematics_ classes::\n\n protobuf_schematics generated_schematics_proto.py # or any output filename\n\n2. Convert your ProtoBuf message to Json:\n\nIn Java:\n\n.. code:: java\n\n import com.google.protobuf.util.JsonFormat;\n\n FileWriter file = new FileWriter(\"protoBufMessage.json\")\n JsonFormat.Printer printer = JsonFormat.printer().preservingProtoFieldNames();\n String message = printer.print(someProtoBufMessage);\n file.write(message)\n\nor from Python:\n\n.. code:: python\n\n import json\n from google.protobuf.json_format import MessageToJson\n\n json = MessageToJson(org, preserving_proto_field_name=True, including_default_value_fields=True)\n with open(\"protoBufMessage.json\", 'w') as output:\n json.dump(json, output)\n\n3. In your project, load the message in python as Schematics_ object:\n\n.. code:: python\n\n import json\n from generated_schematics_proto import SomeMessage # import the schematics message class\n\n schematics_root_message = SomeMessage(json.load(open('protoBufMessage.json')))\n\nOr use a message loaded in python by Protobuf:\n\n.. code:: python\n\n import json\n from generated_schematics_proto import SomeMessage # import the schematics message class\n\n # ... get your protobuf message as the pb class representation\n schematics_root_message = SomeMessage.import_from_protobuf_message(protobuf_message)\n\n\n\nExample\n-------\n\nThis ``proto`` file:\n\n.. code-block:: proto\n\n syntax = \"proto3\";\n\n enum IPAddressFamily {\n INVALID = 0;\n IPv4 = 1;\n IPv6 = 2;\n };\n\n message ProtocolAndPorts {\n repeated uint32 ports = 3;\n }\n\n message FlowFilter {\n enum SomeEnum {\n VALUE = 0;\n };\n string id = 1 [deprecated = true];\n SomeEnum consumer_filter_id = 2;\n map ports = 3;\n repeated ProtocolAndPorts protocol_and_ports = 4;\n }\n\nWill be converted to:\n\n.. code-block:: python3\n\n class IPAddressFamily(Enum):\n INVALID = 0\n IPv4 = 1\n IPv6 = 2\n\n\n class ProtocolAndPorts(ProtobufMessageModel):\n ports = ListType(IntType())\n\n\n class FlowFilter(ProtobufMessageModel):\n class InnerEnum(Enum):\n VALUE = 0\n\n id = StringType()\n consumer_filter_id = EnumType(SomeEnum)\n ports = DictType(ModelType(ProtocolAndPorts), str)\n protocol_and_ports = ListType(ModelType(ProtocolAndPorts))\n\n\n\n\nFeatures\n--------\n\n* Support both Protobuf syntax 2 and 3.\n* Support builtin types such as StringType, ``IntType``.\n* Support proto map fields as Schematics_ ``DictType``.\n* Support ``repeated`` modifier as convert to ``ListType``.\n* Support Enum class generation and custom Schematics ``EnumType``.\n* Support custom schematics ``ByteArrayType`` base64 encoded byte arrays converted from Java.\n\nDevelopment\n-----------\n\nFirst, install the Pipfile and create the proper virtual environment::\n\n pipenv install --dev\n\nTo check linting with **flake8**, run::\n\n make lint\n\nTo run the unittests against your working python version::\n\n py.test\n\nTo see coverage report::\n\n make coverage\n\nTo run tests against all supported python versions::\n\n tox\n\nTo make the docs (which will be automatically published to readthedocs on commits to the master branch)::\n\n make docs\n\nCredits\n-------\n\nThe parsing work of **.proto** files is provided thanks to the awesome guys at PyroBuf_.\n\nThis package was created with Cookiecutter_ and the `elgertam/cookiecutter-pipenv`_ project template, based on `audreyr/cookiecutter-pypackage`_.\n\n.. _Cookiecutter: https://github.com/audreyr/cookiecutter\n.. _`elgertam/cookiecutter-pipenv`: https://github.com/elgertam/cookiecutter-pipenv\n.. _`audreyr/cookiecutter-pypackage`: https://github.com/audreyr/cookiecutter-pypackage\n.. _PyroBuf: https://github.com/appnexus/pyrobuf\n\n\n=======\nHistory\n=======\n\nTODO\n----\n* Add more meaningful unittests.\n* Improve Protobuf support and integration.\n* add support for parsing the Protobuf generated files as it is more comprehensive than the current Pyrobuf support.\n\n\nRead for Release\n----------------\n\n\n0.4.0 (2019-01-16)\n------------------\n\n* Added more meaningful unittests.\n* Export Types and Models out of the templates.\n* Export heavy definition logic (such as field definition) from the jinja template to pythonic filters.\n* Improve integration with Protobuf.\n\n\n0.2.0 (2019-01-14)\n------------------\n\n* Improve README - Add usage examples.\n* Update the setup.py to point to official PyroBuf 0.8.5 PyPi release.\n\n\n0.1.0 (2019-01-13)\n------------------\n\n* First release on PyPI.\n* CLI interface for compiling a given proto file to schematics definition file.\n\n\n", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/AlmogCohen/protobuf-schematics", "keywords": "protobuf_schematics", "license": "Apache Software License 2.0", "maintainer": "", "maintainer_email": "", "name": "protobuf-schematics", "package_url": "https://pypi.org/project/protobuf-schematics/", "platform": "", "project_url": "https://pypi.org/project/protobuf-schematics/", "project_urls": { "Homepage": "https://github.com/AlmogCohen/protobuf-schematics" }, "release_url": "https://pypi.org/project/protobuf-schematics/0.4.1/", "requires_dist": [ "Click (>=6.0)", "jinja2", "pyrobuf (>=0.8.5)", "protobuf", "schematics", "typing", "six" ], "requires_python": "", "summary": "Convert ProtoBuf proto file to cute Schematics classes file", "version": "0.4.1" }, "last_serial": 4772556, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "07bc04f86380d5c0182333d44c1b18e2", "sha256": "a09ee14c43e211f08ddef0fd7fdda9f23d93cec9eebe47f8d439668a428688a9" }, "downloads": -1, "filename": "protobuf_schematics-0.1.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "07bc04f86380d5c0182333d44c1b18e2", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 5133, "upload_time": "2019-01-14T06:50:22", "url": "https://files.pythonhosted.org/packages/42/bd/445f1b1c1ed0466dc78670344793dd29c38fb10968aaa7b40cdc85f50be3/protobuf_schematics-0.1.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "c2dc22a9e20884067d907a06b1754ddf", "sha256": "deb13a909689ef2d7b70317c1c74867e055e12c51e683e2cd8ef4b0a92d7c9fe" }, "downloads": -1, "filename": "protobuf_schematics-0.1.0.tar.gz", "has_sig": false, "md5_digest": "c2dc22a9e20884067d907a06b1754ddf", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9800, "upload_time": "2019-01-14T06:50:24", "url": "https://files.pythonhosted.org/packages/2b/5b/357709e2ac99c5542fb18d7b2f5089630e29a8ff593d257067850d40b76d/protobuf_schematics-0.1.0.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "fd5f0c6cd815486cb20c25aa1ac70ebc", "sha256": "d7bd7073e6e0c996bde04f45187da7bbb2da8a406c6935525d7589540d499567" }, "downloads": -1, "filename": "protobuf_schematics-0.2.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "fd5f0c6cd815486cb20c25aa1ac70ebc", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 5781, "upload_time": "2019-01-14T20:15:05", "url": "https://files.pythonhosted.org/packages/5b/b3/1887b991bb19e8a0eb00b87a16b1546e9d08c4609424cf34a8b2eb636f8d/protobuf_schematics-0.2.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "b1dd87744a3c804cf4a22e5059a6d178", "sha256": "84cc60814a2078758adebe8a56158f282e64b6d29c765cc937de40d4baf84f95" }, "downloads": -1, "filename": "protobuf_schematics-0.2.0.tar.gz", "has_sig": false, "md5_digest": "b1dd87744a3c804cf4a22e5059a6d178", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10912, "upload_time": "2019-01-14T20:15:07", "url": "https://files.pythonhosted.org/packages/80/bc/e92ba9fb7feb02a5715ac9ac40145e9c3036a3591efda7aaf7ca50c21cce/protobuf_schematics-0.2.0.tar.gz" } ], "0.3.0": [ { "comment_text": "", "digests": { "md5": "feacc7ed1414a262493c95d73626615c", "sha256": "a6c57c5e80542321bc0962ef4bb7fb903685e8426fb265a03e4e4baeceabb41e" }, "downloads": -1, "filename": "protobuf_schematics-0.3.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "feacc7ed1414a262493c95d73626615c", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 6952, "upload_time": "2019-01-14T23:08:31", "url": "https://files.pythonhosted.org/packages/e4/c1/32d18d89505c2e7014184afbcd7e54cc8a7514b8ddf38fb6ed66a86d4c42/protobuf_schematics-0.3.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "02860331debe7eda2c127c147f016df2", "sha256": "f5ab809ad1e86c76874caf409a5a87839b6b967ce45832322b9446682d02a076" }, "downloads": -1, "filename": "protobuf_schematics-0.3.0.tar.gz", "has_sig": false, "md5_digest": "02860331debe7eda2c127c147f016df2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14212, "upload_time": "2019-01-14T23:08:33", "url": "https://files.pythonhosted.org/packages/aa/07/b58cae98090ad84efc4753c425af536b3783c3ff95c15469266168f70d1c/protobuf_schematics-0.3.0.tar.gz" } ], "0.4.0": [ { "comment_text": "", "digests": { "md5": "b675bcd6b64161590bcbba5af68239ee", "sha256": "5a4dce209bef16e36e6eb6006827bcd7cb89618816a4104f61282e463d5123de" }, "downloads": -1, "filename": "protobuf_schematics-0.4.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "b675bcd6b64161590bcbba5af68239ee", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 8617, "upload_time": "2019-01-16T22:31:37", "url": "https://files.pythonhosted.org/packages/4c/3b/b48f086cb5e9834325520a0b76509ac324e7d5855ad84994daca669a2709/protobuf_schematics-0.4.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "3810a262276d01f832e06ee1021730b2", "sha256": "d99a81ee1ae45f59d5ad1d0bb8974dda9090a6ce6a3d1e911d255ae0d8c8b51a" }, "downloads": -1, "filename": "protobuf_schematics-0.4.0.tar.gz", "has_sig": false, "md5_digest": "3810a262276d01f832e06ee1021730b2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 15417, "upload_time": "2019-01-16T22:31:39", "url": "https://files.pythonhosted.org/packages/dc/e8/bd4a9e5f95cca087df2a6e893fd715533fb5c136857d7d752eb1a3499c95/protobuf_schematics-0.4.0.tar.gz" } ], "0.4.1": [ { "comment_text": "", "digests": { "md5": "410c9b134cc12d121451b65245ce46fb", "sha256": "3b203893d61e27e303982719f85609706048ebed3c4bc8068d308ea237b64c55" }, "downloads": -1, "filename": "protobuf_schematics-0.4.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "410c9b134cc12d121451b65245ce46fb", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 8895, "upload_time": "2019-02-02T16:16:32", "url": "https://files.pythonhosted.org/packages/8e/aa/beb58a77b5f7b777e0ca664035069e86ca48dd8725ff6359e29b7efd07b8/protobuf_schematics-0.4.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "b4755578d7d786a26e3f06241dd69e8b", "sha256": "b401ac3e657737b9c51b8f5aad93e14726d5a926ecefbdb73f04cc6d26c53d97" }, "downloads": -1, "filename": "protobuf_schematics-0.4.1.tar.gz", "has_sig": false, "md5_digest": "b4755578d7d786a26e3f06241dd69e8b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 16172, "upload_time": "2019-02-02T16:16:33", "url": "https://files.pythonhosted.org/packages/64/ce/3cd78f17239db2a41924844beab2ade1d4a6364f4ab588f6ee7ed9dd19ed/protobuf_schematics-0.4.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "410c9b134cc12d121451b65245ce46fb", "sha256": "3b203893d61e27e303982719f85609706048ebed3c4bc8068d308ea237b64c55" }, "downloads": -1, "filename": "protobuf_schematics-0.4.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "410c9b134cc12d121451b65245ce46fb", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 8895, "upload_time": "2019-02-02T16:16:32", "url": "https://files.pythonhosted.org/packages/8e/aa/beb58a77b5f7b777e0ca664035069e86ca48dd8725ff6359e29b7efd07b8/protobuf_schematics-0.4.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "b4755578d7d786a26e3f06241dd69e8b", "sha256": "b401ac3e657737b9c51b8f5aad93e14726d5a926ecefbdb73f04cc6d26c53d97" }, "downloads": -1, "filename": "protobuf_schematics-0.4.1.tar.gz", "has_sig": false, "md5_digest": "b4755578d7d786a26e3f06241dd69e8b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 16172, "upload_time": "2019-02-02T16:16:33", "url": "https://files.pythonhosted.org/packages/64/ce/3cd78f17239db2a41924844beab2ade1d4a6364f4ab588f6ee7ed9dd19ed/protobuf_schematics-0.4.1.tar.gz" } ] }