Skip to main content

proto2obj

This Python library converts Protocol Buffers (Protobuf) messages into Python classes, mapping each message member to a class property. The main purpose of this library is to enable inheritance from Protobuf messages. Instead of inheriting directly from the Protobuf message (which is impossible), it inherits from a proxy class that shares the same data structure and can be converted back to Protobuf message data.

Installation

pip install proto2obj

Example of usage :

Example 1 :

from proto2obj import Proto2Obj 


# msg is a protobuff message type 

fake_msg_type = Proto2Obj(msg).convert()
#def convert(self,base = tuple() , attrs = dict()) :
#   base  = baseclasses , to generate the new type as drived from base classes 
#   attrs = extra static memebers assigned to new generated type 

# get fields  : 
print(f"Message fields : {instance.__fields__}")
# get enums 
print(f"Message enums : {instance.__enums__}")
# get nested types , they are converted also 
print(f"Message nested types : {instance.__nested_types__}")
# the original protobuff message which is converted from 
print(f"Message original  protobuff message  : {instance.__protobuf__}")

## create instance 
instance = fake_msg_type(var = value , ....)

# assigne memebers like normal python object 
instance.var = value2

# convert back to protobuff instance 
msg_instance = instance.proto()

Example 2 :

from proto2obj import Proto2Obj 


# msg is a protobuff message type 

fake_msg_type = Proto2Obj(msg).convert()


class DrivedType(fake_msg_type) : 
    pass 

instance = DrivedType(var = value , ....)

Metadata

Release files for proto2obj 1.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for proto2obj 1.0.2
File Size Uploaded Provenance Actions
proto2obj-1.0.2.tar.gz 4.5 kB Without provenance Details for proto2obj-1.0.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for proto2obj 1.0.2
File Interpreter ABI Platform Actions
proto2obj-1.0.2-py3-none-any.whl Python 3 none any Details for proto2obj-1.0.2-py3-none-any.whl

Total release size: 8.5 kB

Release files / proto2obj-1.0.2.tar.gz

Download URL proto2obj-1.0.2.tar.gz
Size 4.5 kB
Tags Source
SHA-256 checksum
How to use checksums
8a5a0a1ac7f3f7bd4b91d8dd1b70bc3645f215ed9069efb946c57fe74d04928a
BLAKE2b-256 checksum
How to use checksums
889f2c39b349fa3467001f3471e014a6cae816063a20987b76eb05efa6b5c63e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.10.12

Release files / proto2obj-1.0.2-py3-none-any.whl

Download URL proto2obj-1.0.2-py3-none-any.whl
Size 4.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5151c4cb218ec42b5862cbcfebaa43d3f6ea89d1ea230100ff42b57b7349a0ec
BLAKE2b-256 checksum
How to use checksums
0b222b63502287a9a4fd7792a56814c374ef5392fd32dd949a9cb9765f1fdafb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.10.12

Security for proto2obj 1.0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.2 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page