I am trying to use FileOptions defined in a proto file to do some 
validations on the auto-generated python classes, which will drive some 
integrations further downstream. 

I couldn't find a way to access the FileOptions, which are serialized and 
stored under `serialized_options` in the generated python classes. 

*sample.proto*
```
option (foo.pkg.v1.option1) = option_val1; 
option (foo.pkg.v1.option2) = option_val2; 
option (foo.pkg.v1.option3) = "Sample desc"; 
option (foo.pkg.v1.option4) = option_val4; 
option (foo.pkg.v1.option5) = option_val5; .....
```
  

*sample_pb2.py*
DESCRIPTOR = _descriptor.FileDescriptor( name='foo/bar/v1/baz.proto', 
package='foo.bar.v1', syntax='proto3', 
serialized_options=b'\240\227\"d\220\227\"\364\034\252\227\"nSample 
desc\210\227\"\350 \230\227\"d', 
create_key=_descriptor._internal_create_key, 
serialized_pb=b'\n9foo/bar/v1/baz.proto\x12\x0f\x63hime.bar.v1\x1a*foo/bar/v1/external_source_info.proto\x1a\x1a\x63hime/pii/v1/options.proto\x1a!foo/streaming/v1/metadata.proto\x1a\x17google/type/money.proto\"\xdf\x02\n
 
ExternalDirectDepositAllocations\x12\x1b\n\x13\x65xternal_account_id\x18\x01 
\x01(\t\x12\x38\n\x0f\x65xternal_source\x18\x02 
\x01(\x0e\x32\x1f.foo.bar.v1.ExternalSource\x12\x1b\n\x13\x61llocation_group_id\x18\x03
 
\x01(\t\x12\x14\n\x0c\x61\x63\x63ount_type\x18\x04 
\x01(\t\x12\x38\n\x0f\x61llocation_type\x18\x05 
\x01(\x0e\x32\x1f.foo.bar.v1.AllocationType\x12(\n\x06\x61mount\x18\x06 
\x01(\x0b\x32\x12.google.type.MoneyB\x04\x88\xb5\x18,\x12\x14\n\x0c\x61\x63\x63ount_name\x18\x07
 
\x01(\t\x12\x11\n\tbank_name\x18\x08 \x01(\t\x12\x12\n\npercentage\x18\t 
\x01(\x01\x12\x10\n\x08priority\x18\n 
\x01(\x03\x42\x84\x01\xa0\x97\"d\x90\x97\"\xf4\x1c\xaa\x97\"nSample 
desc\x88\x97\"\xe8 \x98\x97\"db\x06proto3' , 
dependencies=[foo_dot_bar_dot_v1_dot_external__source__info__pb2.DESCRIPTOR,foo_dot_streaming_dot_v1_dot_metadata__pb2.DESCRIPTOR,google_dot_type_dot_money__pb2.DESCRIPTOR,])
 


How can we access the FileOptions foo.pkg.v1.option1, foo.pkg.v1.option2, 
etc in python?
protobuf_obj.DESCRIPTOR.GetOptions() 

does not return anything.

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/protobuf/6c05086d-c04d-401f-bf7a-9c8fb1188938n%40googlegroups.com.

Reply via email to