Skip to main content

Python Package made by Mhadhbi Issam .

Project description

proto2obj

Python library to convert Protobuff message to python classes , where each message memeber is mapped into class property . This library created for main purpose is to be able to inhirt from Protobuff message , but insted of meessage inhirit from fake class that share same data , and convertable to meesgae Protobuff 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 , ....)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

proto2obj-1.0.1.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

proto2obj-1.0.1-py3-none-any.whl (3.9 kB view details)

Uploaded Python 3

File details

Details for the file proto2obj-1.0.1.tar.gz.

File metadata

  • Download URL: proto2obj-1.0.1.tar.gz
  • Upload date:
  • Size: 4.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.12

File hashes

Hashes for proto2obj-1.0.1.tar.gz
Algorithm Hash digest
SHA256 61c8f448ca545ddb4c04cfb533d5dc3fc0b686bb70af2e2371f85a4a105510a0
MD5 3f312e6c202461bf5738bb7c7d8efaca
BLAKE2b-256 bc8dc10217b5fdf4acd0d70c145257191bd92fb39cd6064743b9b29dc7270577

See more details on using hashes here.

File details

Details for the file proto2obj-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: proto2obj-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 3.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.12

File hashes

Hashes for proto2obj-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ae231644998689c781bbbcf0184120239eb889ca6fbd39394d0bc004729835d6
MD5 b245111fd214061d90b0dce0839c7b88
BLAKE2b-256 01831be9adf49bb45a0023fdcf2f3190b8c4e24145efff5734a1b2e3cc250751

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page