Metadata-Version: 2.1
Name: proto2obj
Version: 1.0.2
Summary: Python Package made by Mhadhbi Issam . 
Home-page: https://gitlab.com/game-dev-comapny/libraries/proto2obj.git
Author: mhadhbixissam
Author-email: mhadhbixissam@gmail.com
Project-URL: Documentation, https://pydefold.readthedocs.io/en/latest/
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Description-Content-Type: text/markdown
Requires-Dist: protobuf==4.25.0

# 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 
```bash
pip install proto2obj
```


## Example of usage  : 
### Example 1 : 
```python
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 : 
```python
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 , ....)
```
