Install
pip install python-protobuf
Example
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)
Metadata
Release files for python-protobuf 0.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| python-protobuf-0.0.2.tar.gz | 4.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| python_protobuf-0.0.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 9.8 kB
Release files / python-protobuf-0.0.2.tar.gz
| Download URL | python-protobuf-0.0.2.tar.gz |
|---|---|
| Size | 4.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f8b8b4043b38ba133a1e09d987a910bbfb4ccd317fc743412557036eab0920c2
|
|
BLAKE2b-256 checksum How to use checksums |
dd4c3f9db1c8df1c041333963fd453be6fbc2b3c821cfc76385f655cc7137f50
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.6
|
Release files / python_protobuf-0.0.2-py3-none-any.whl
| Download URL | python_protobuf-0.0.2-py3-none-any.whl |
|---|---|
| Size | 4.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
71c1333966b82cec2d48dec0ec2009fe7a8d611415f8717a6a6785269aeb1b07
|
|
BLAKE2b-256 checksum How to use checksums |
aa202b70d20960f048fdb0bb370db922c7f3ea40b49e95a52e0cade848ec1798
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.6
|