How to get top-level protobuf enum value name by number in python?

Viewed 62709

For example, I have proto-file File.proto:

enum Test {
  ONE = 1;
  TWO = 2;
}

I generate file File_pb2.py with protoc from File.proto. I want in a python-code get string "ONE" (that corresponds to the name of File_pb2.ONE) by value 1 (that corresponds to the value of File_pb2.ONE) from generated file File_pb2.py without defining my own dictionaries. How can I do that?

1 Answers
Related