I have a .proto file, describing a given schema and following proto2 syntax. I would like to read this file in python, and generate a structure that I can then manipulate (can be JSON, a python data structure, a proto-specific structure, w/e), in which I have the field names, their types, their optional/required tags, etc. I then want to loop around those fields and print them.
Conceptually, something like this:
my_schema = parseFrom(my_proto.proto)
for field in my_schema["fields"]:
print(field["name"])
How can I do so? I am fiddling around with proto python API, but I am a bit. I did manage to create a FileDescriptorProto from my proto file, and add it to a DescriptorPool. But from there, I do not understand how I can get a DescriptorProto.