python-protobuf


Namepython-protobuf JSON
Version 0.0.2 PyPI version JSON
download
home_page
SummaryPython Protobuf Package
upload_time2023-10-25 09:58:23
maintainer
docs_urlNone
authorTekky
requires_python
license
keywords python protobuf proto dict encode protocol
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
### Install
```
pip install python-protobuf
```

### Example
```py
from pyproto import Protobuf

print("Test the conversion between protobuf and bytes")
bs = bytes.fromhex("12001a0022020801") # A section of bytes data of protobuf
print("src:", bs.hex())
proto = ProtoBuf(bs)  # Convert bytes to protobuf objects
proto.dump()  # print proto object
bs2 = proto.toBuf()  # Convert the proto object to bytes
print(bs2 == bs, bs2.hex())

print("Mutual conversion between proto object and dict object")
# A complex dict object

d = {
    6: {
        1: {
            1: "eyJhbGciOiJIUzI1NiJ9.ODYxODAyNjMyNjcwMA.KGj7v_WjlntNODpPNe4fVbJA5sPhLjZbQidBLhcrGVM"
        },
        3: "5******7@*****.com",
        4: {1: 6},
        5: {1: 1},
        6: {2: "", 3: "", 4: {1: 1}},
    }
}

# An unassigned dict object template

d2 = {6: {1: {1: ""}, 3: "", 4: {1: 0}, 5: {1: 0}, 6: {2: "", 3: "", 4: {1: 0}}}}
print("src:", d)
pb = ProtoBuf(d)  # Convert dict object to protobuf object

pb.dump()

d3 = pb.toDict(d2)  # Convert protobuf object to dict object

print("d3 == d2 ->", d3 == d2, d3 is d2, d3)
print("d3 == d  ->", d3 == d, d3 is d)
```

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "python-protobuf",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "python,protobuf,proto,dict,encode,protocol",
    "author": "Tekky",
    "author_email": "<support@g4f.ai>",
    "download_url": "https://files.pythonhosted.org/packages/dd/4c/3f9db1c8df1c041333963fd453be6fbc2b3c821cfc76385f655cc7137f50/python-protobuf-0.0.2.tar.gz",
    "platform": null,
    "description": "\n### Install\n```\npip install python-protobuf\n```\n\n### Example\n```py\nfrom pyproto import Protobuf\n\nprint(\"Test the conversion between protobuf and bytes\")\nbs = bytes.fromhex(\"12001a0022020801\") # A section of bytes data of protobuf\nprint(\"src:\", bs.hex())\nproto = ProtoBuf(bs)  # Convert bytes to protobuf objects\nproto.dump()  # print proto object\nbs2 = proto.toBuf()  # Convert the proto object to bytes\nprint(bs2 == bs, bs2.hex())\n\nprint(\"Mutual conversion between proto object and dict object\")\n# A complex dict object\n\nd = {\n    6: {\n        1: {\n            1: \"eyJhbGciOiJIUzI1NiJ9.ODYxODAyNjMyNjcwMA.KGj7v_WjlntNODpPNe4fVbJA5sPhLjZbQidBLhcrGVM\"\n        },\n        3: \"5******7@*****.com\",\n        4: {1: 6},\n        5: {1: 1},\n        6: {2: \"\", 3: \"\", 4: {1: 1}},\n    }\n}\n\n# An unassigned dict object template\n\nd2 = {6: {1: {1: \"\"}, 3: \"\", 4: {1: 0}, 5: {1: 0}, 6: {2: \"\", 3: \"\", 4: {1: 0}}}}\nprint(\"src:\", d)\npb = ProtoBuf(d)  # Convert dict object to protobuf object\n\npb.dump()\n\nd3 = pb.toDict(d2)  # Convert protobuf object to dict object\n\nprint(\"d3 == d2 ->\", d3 == d2, d3 is d2, d3)\nprint(\"d3 == d  ->\", d3 == d, d3 is d)\n```\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Python Protobuf Package",
    "version": "0.0.2",
    "project_urls": null,
    "split_keywords": [
        "python",
        "protobuf",
        "proto",
        "dict",
        "encode",
        "protocol"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "aa202b70d20960f048fdb0bb370db922c7f3ea40b49e95a52e0cade848ec1798",
                "md5": "611a9704f4a2a69bf9ca1d2570bc11e9",
                "sha256": "71c1333966b82cec2d48dec0ec2009fe7a8d611415f8717a6a6785269aeb1b07"
            },
            "downloads": -1,
            "filename": "python_protobuf-0.0.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "611a9704f4a2a69bf9ca1d2570bc11e9",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 4948,
            "upload_time": "2023-10-25T09:58:21",
            "upload_time_iso_8601": "2023-10-25T09:58:21.620154Z",
            "url": "https://files.pythonhosted.org/packages/aa/20/2b70d20960f048fdb0bb370db922c7f3ea40b49e95a52e0cade848ec1798/python_protobuf-0.0.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "dd4c3f9db1c8df1c041333963fd453be6fbc2b3c821cfc76385f655cc7137f50",
                "md5": "c7312fb98bab556e77882a82906988eb",
                "sha256": "f8b8b4043b38ba133a1e09d987a910bbfb4ccd317fc743412557036eab0920c2"
            },
            "downloads": -1,
            "filename": "python-protobuf-0.0.2.tar.gz",
            "has_sig": false,
            "md5_digest": "c7312fb98bab556e77882a82906988eb",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 4857,
            "upload_time": "2023-10-25T09:58:23",
            "upload_time_iso_8601": "2023-10-25T09:58:23.262163Z",
            "url": "https://files.pythonhosted.org/packages/dd/4c/3f9db1c8df1c041333963fd453be6fbc2b3c821cfc76385f655cc7137f50/python-protobuf-0.0.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-10-25 09:58:23",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "python-protobuf"
}
        
Elapsed time: 0.15995s