def _ConvertEnumDescriptor(self, enum_proto, package=None, file_desc=None, containing_type=None, scope=None): """Make a protobuf EnumDescriptor given an EnumDescriptorProto protobuf. Args: enum_proto: The descriptor_pb2.EnumDescriptorProto protobuf message. package: Optional package name for the new message EnumDescriptor. file_desc: The file containing the enum descriptor. containing_type: The type containing this enum. scope: Scope containing available types. Returns: The added descriptor """ if package: enum_name = '.'.join((package, enum_proto.name)) else: enum_name = enum_proto.name if file_desc is None: file_name = None else: file_name = file_desc.name values = [ self._MakeEnumValueDescriptor(value, index) for index, value in enumerate(enum_proto.value) ] desc = descriptor.EnumDescriptor(name=enum_proto.name, full_name=enum_name, filename=file_name, file=file_desc, values=values, containing_type=containing_type, options=_OptionsOrNone(enum_proto)) scope['.%s' % enum_name] = desc self._CheckConflictRegister(desc) self._enum_descriptors[enum_name] = desc return desc
public_dependencies=[ google_dot_protobuf_dot_internal_dot_more__messages__pb2.DESCRIPTOR, ]) _DESCRIPTORPOOLTEST3_NESTEDMESSAGE_DEEPNESTEDMESSAGE_NESTEDENUM = _descriptor.EnumDescriptor( name='NestedEnum', full_name= 'google.protobuf.python.internal.DescriptorPoolTest3.NestedMessage.DeepNestedMessage.NestedEnum', filename=None, file=DESCRIPTOR, values=[ _descriptor.EnumValueDescriptor(name='RHO', index=0, number=17, serialized_options=None, type=None), _descriptor.EnumValueDescriptor(name='SIGMA', index=1, number=18, serialized_options=None, type=None), ], containing_type=None, serialized_options=None, serialized_start=832, serialized_end=864, ) _sym_db.RegisterEnumDescriptor( _DESCRIPTORPOOLTEST3_NESTEDMESSAGE_DEEPNESTEDMESSAGE_NESTEDENUM) _DESCRIPTORPOOLTEST3_NESTEDMESSAGE_NESTEDENUM = _descriptor.EnumDescriptor(
dependencies=[ google_dot_protobuf_dot_any__pb2.DESCRIPTOR, google_dot_protobuf_dot_source__context__pb2.DESCRIPTOR, ]) _SYNTAX = _descriptor.EnumDescriptor( name='Syntax', full_name='google.protobuf.Syntax', filename=None, file=DESCRIPTOR, values=[ _descriptor.EnumValueDescriptor(name='SYNTAX_PROTO2', index=0, number=0, serialized_options=None, type=None), _descriptor.EnumValueDescriptor(name='SYNTAX_PROTO3', index=1, number=1, serialized_options=None, type=None), ], containing_type=None, serialized_options=None, serialized_start=1413, serialized_end=1459, ) _sym_db.RegisterEnumDescriptor(_SYNTAX) Syntax = enum_type_wrapper.EnumTypeWrapper(_SYNTAX) SYNTAX_PROTO2 = 0 SYNTAX_PROTO3 = 1
package='google.protobuf.no_generic_services_test', syntax='proto2', serialized_options=None, serialized_pb=_b( '\n2google/protobuf/unittest_no_generic_services.proto\x12(google.protobuf.no_generic_services_test\"#\n\x0bTestMessage\x12\t\n\x01\x61\x18\x01 \x01(\x05*\t\x08\xe8\x07\x10\x80\x80\x80\x80\x02*\x13\n\x08TestEnum\x12\x07\n\x03\x46OO\x10\x01\x32\x82\x01\n\x0bTestService\x12s\n\x03\x46oo\x12\x35.google.protobuf.no_generic_services_test.TestMessage\x1a\x35.google.protobuf.no_generic_services_test.TestMessage:N\n\x0etest_extension\x12\x35.google.protobuf.no_generic_services_test.TestMessage\x18\xe8\x07 \x01(\x05' )) _TESTENUM = _descriptor.EnumDescriptor( name='TestEnum', full_name='google.protobuf.no_generic_services_test.TestEnum', filename=None, file=DESCRIPTOR, values=[ _descriptor.EnumValueDescriptor(name='FOO', index=0, number=1, serialized_options=None, type=None), ], containing_type=None, serialized_options=None, serialized_start=133, serialized_end=152, ) _sym_db.RegisterEnumDescriptor(_TESTENUM) TestEnum = enum_type_wrapper.EnumTypeWrapper(_TESTENUM) FOO = 1 TEST_EXTENSION_FIELD_NUMBER = 1000 test_extension = _descriptor.FieldDescriptor(
serialized_options=_b( '\n\023com.google.protobufB\013StructProtoP\001Z1github.com/golang/protobuf/ptypes/struct;structpb\370\001\001\242\002\003GPB\252\002\036Google.Protobuf.WellKnownTypes' ), serialized_pb=_b( '\n\x1cgoogle/protobuf/struct.proto\x12\x0fgoogle.protobuf\"\x84\x01\n\x06Struct\x12\x33\n\x06\x66ields\x18\x01 \x03(\x0b\x32#.google.protobuf.Struct.FieldsEntry\x1a\x45\n\x0b\x46ieldsEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12%\n\x05value\x18\x02 \x01(\x0b\x32\x16.google.protobuf.Value:\x02\x38\x01\"\xea\x01\n\x05Value\x12\x30\n\nnull_value\x18\x01 \x01(\x0e\x32\x1a.google.protobuf.NullValueH\x00\x12\x16\n\x0cnumber_value\x18\x02 \x01(\x01H\x00\x12\x16\n\x0cstring_value\x18\x03 \x01(\tH\x00\x12\x14\n\nbool_value\x18\x04 \x01(\x08H\x00\x12/\n\x0cstruct_value\x18\x05 \x01(\x0b\x32\x17.google.protobuf.StructH\x00\x12\x30\n\nlist_value\x18\x06 \x01(\x0b\x32\x1a.google.protobuf.ListValueH\x00\x42\x06\n\x04kind\"3\n\tListValue\x12&\n\x06values\x18\x01 \x03(\x0b\x32\x16.google.protobuf.Value*\x1b\n\tNullValue\x12\x0e\n\nNULL_VALUE\x10\x00\x42\x81\x01\n\x13\x63om.google.protobufB\x0bStructProtoP\x01Z1github.com/golang/protobuf/ptypes/struct;structpb\xf8\x01\x01\xa2\x02\x03GPB\xaa\x02\x1eGoogle.Protobuf.WellKnownTypesb\x06proto3' )) _NULLVALUE = _descriptor.EnumDescriptor( name='NullValue', full_name='google.protobuf.NullValue', filename=None, file=DESCRIPTOR, values=[ _descriptor.EnumValueDescriptor(name='NULL_VALUE', index=0, number=0, serialized_options=None, type=None), ], containing_type=None, serialized_options=None, serialized_start=474, serialized_end=501, ) _sym_db.RegisterEnumDescriptor(_NULLVALUE) NullValue = enum_type_wrapper.EnumTypeWrapper(_NULLVALUE) NULL_VALUE = 0 _STRUCT_FIELDSENTRY = _descriptor.Descriptor( name='FieldsEntry',
serialized_pb=_b( '\n4google/protobuf/internal/descriptor_pool_test1.proto\x12\x1fgoogle.protobuf.python.internal\"\xfb\x05\n\x13\x44\x65scriptorPoolTest1\x12Z\n\x0bnested_enum\x18\x01 \x01(\x0e\x32?.google.protobuf.python.internal.DescriptorPoolTest1.NestedEnum:\x04\x42\x45TA\x12Z\n\x0enested_message\x18\x02 \x01(\x0b\x32\x42.google.protobuf.python.internal.DescriptorPoolTest1.NestedMessage\x1a\xfd\x03\n\rNestedMessage\x12h\n\x0bnested_enum\x18\x01 \x01(\x0e\x32M.google.protobuf.python.internal.DescriptorPoolTest1.NestedMessage.NestedEnum:\x04ZETA\x12\x1a\n\x0cnested_field\x18\x02 \x01(\t:\x04\x62\x65ta\x12q\n\x13\x64\x65\x65p_nested_message\x18\x03 \x01(\x0b\x32T.google.protobuf.python.internal.DescriptorPoolTest1.NestedMessage.DeepNestedMessage\x1a\xcd\x01\n\x11\x44\x65\x65pNestedMessage\x12y\n\x0bnested_enum\x18\x01 \x01(\x0e\x32_.google.protobuf.python.internal.DescriptorPoolTest1.NestedMessage.DeepNestedMessage.NestedEnum:\x03\x45TA\x12\x1b\n\x0cnested_field\x18\x02 \x01(\t:\x05theta\" \n\nNestedEnum\x12\x07\n\x03\x45TA\x10\x07\x12\t\n\x05THETA\x10\x08\"#\n\nNestedEnum\x12\x0b\n\x07\x45PSILON\x10\x05\x12\x08\n\x04ZETA\x10\x06\"!\n\nNestedEnum\x12\t\n\x05\x41LPHA\x10\x01\x12\x08\n\x04\x42\x45TA\x10\x02*\t\x08\xe8\x07\x10\x80\x80\x80\x80\x02\"\xf1\x05\n\x13\x44\x65scriptorPoolTest2\x12[\n\x0bnested_enum\x18\x01 \x01(\x0e\x32?.google.protobuf.python.internal.DescriptorPoolTest2.NestedEnum:\x05GAMMA\x12Z\n\x0enested_message\x18\x02 \x01(\x0b\x32\x42.google.protobuf.python.internal.DescriptorPoolTest2.NestedMessage\x1a\xfc\x03\n\rNestedMessage\x12h\n\x0bnested_enum\x18\x01 \x01(\x0e\x32M.google.protobuf.python.internal.DescriptorPoolTest2.NestedMessage.NestedEnum:\x04IOTA\x12\x1b\n\x0cnested_field\x18\x02 \x01(\t:\x05\x64\x65lta\x12q\n\x13\x64\x65\x65p_nested_message\x18\x03 \x01(\x0b\x32T.google.protobuf.python.internal.DescriptorPoolTest2.NestedMessage.DeepNestedMessage\x1a\xcd\x01\n\x11\x44\x65\x65pNestedMessage\x12x\n\x0bnested_enum\x18\x01 \x01(\x0e\x32_.google.protobuf.python.internal.DescriptorPoolTest2.NestedMessage.DeepNestedMessage.NestedEnum:\x02MU\x12\x1c\n\x0cnested_field\x18\x02 \x01(\t:\x06lambda\" \n\nNestedEnum\x12\n\n\x06LAMBDA\x10\x0b\x12\x06\n\x02MU\x10\x0c\"!\n\nNestedEnum\x12\x08\n\x04IOTA\x10\t\x12\t\n\x05KAPPA\x10\n\"\"\n\nNestedEnum\x12\t\n\x05GAMMA\x10\x03\x12\t\n\x05\x44\x45LTA\x10\x04' )) _DESCRIPTORPOOLTEST1_NESTEDMESSAGE_DEEPNESTEDMESSAGE_NESTEDENUM = _descriptor.EnumDescriptor( name='NestedEnum', full_name= 'google.protobuf.python.internal.DescriptorPoolTest1.NestedMessage.DeepNestedMessage.NestedEnum', filename=None, file=DESCRIPTOR, values=[ _descriptor.EnumValueDescriptor(name='ETA', index=0, number=7, serialized_options=None, type=None), _descriptor.EnumValueDescriptor(name='THETA', index=1, number=8, serialized_options=None, type=None), ], containing_type=None, serialized_options=None, serialized_start=738, serialized_end=770, ) _sym_db.RegisterEnumDescriptor( _DESCRIPTORPOOLTEST1_NESTEDMESSAGE_DEEPNESTEDMESSAGE_NESTEDENUM) _DESCRIPTORPOOLTEST1_NESTEDMESSAGE_NESTEDENUM = _descriptor.EnumDescriptor(
serialized_options=None, serialized_pb=_b('\n2google/protobuf/internal/missing_enum_values.proto\x12\x1fgoogle.protobuf.python.internal\"\xc1\x02\n\x0eTestEnumValues\x12X\n\x14optional_nested_enum\x18\x01 \x01(\x0e\x32:.google.protobuf.python.internal.TestEnumValues.NestedEnum\x12X\n\x14repeated_nested_enum\x18\x02 \x03(\x0e\x32:.google.protobuf.python.internal.TestEnumValues.NestedEnum\x12Z\n\x12packed_nested_enum\x18\x03 \x03(\x0e\x32:.google.protobuf.python.internal.TestEnumValues.NestedEnumB\x02\x10\x01\"\x1f\n\nNestedEnum\x12\x08\n\x04ZERO\x10\x00\x12\x07\n\x03ONE\x10\x01\"\xd3\x02\n\x15TestMissingEnumValues\x12_\n\x14optional_nested_enum\x18\x01 \x01(\x0e\x32\x41.google.protobuf.python.internal.TestMissingEnumValues.NestedEnum\x12_\n\x14repeated_nested_enum\x18\x02 \x03(\x0e\x32\x41.google.protobuf.python.internal.TestMissingEnumValues.NestedEnum\x12\x61\n\x12packed_nested_enum\x18\x03 \x03(\x0e\x32\x41.google.protobuf.python.internal.TestMissingEnumValues.NestedEnumB\x02\x10\x01\"\x15\n\nNestedEnum\x12\x07\n\x03TWO\x10\x02\"\x1b\n\nJustString\x12\r\n\x05\x64ummy\x18\x01 \x02(\t') ) _TESTENUMVALUES_NESTEDENUM = _descriptor.EnumDescriptor( name='NestedEnum', full_name='google.protobuf.python.internal.TestEnumValues.NestedEnum', filename=None, file=DESCRIPTOR, values=[ _descriptor.EnumValueDescriptor( name='ZERO', index=0, number=0, serialized_options=None, type=None), _descriptor.EnumValueDescriptor( name='ONE', index=1, number=1, serialized_options=None, type=None), ], containing_type=None, serialized_options=None, serialized_start=378, serialized_end=409, ) _sym_db.RegisterEnumDescriptor(_TESTENUMVALUES_NESTEDENUM) _TESTMISSINGENUMVALUES_NESTEDENUM = _descriptor.EnumDescriptor( name='NestedEnum', full_name='google.protobuf.python.internal.TestMissingEnumValues.NestedEnum', filename=None,
), dependencies=[ google_dot_protobuf_dot_internal_dot_factory__test1__pb2.DESCRIPTOR, ]) _FACTORY2ENUM = _descriptor.EnumDescriptor( name='Factory2Enum', full_name='google.protobuf.python.internal.Factory2Enum', filename=None, file=DESCRIPTOR, values=[ _descriptor.EnumValueDescriptor(name='FACTORY_2_VALUE_0', index=0, number=0, serialized_options=None, type=None), _descriptor.EnumValueDescriptor(name='FACTORY_2_VALUE_1', index=1, number=1, serialized_options=None, type=None), ], containing_type=None, serialized_options=None, serialized_start=1816, serialized_end=1876, ) _sym_db.RegisterEnumDescriptor(_FACTORY2ENUM) Factory2Enum = enum_type_wrapper.EnumTypeWrapper(_FACTORY2ENUM) FACTORY_2_VALUE_0 = 0 FACTORY_2_VALUE_1 = 1
serialized_options=None, serialized_pb=_b( '\n,google/protobuf/internal/factory_test1.proto\x12\x1fgoogle.protobuf.python.internal\"\xd5\x03\n\x0f\x46\x61\x63tory1Message\x12\x45\n\x0e\x66\x61\x63tory_1_enum\x18\x01 \x01(\x0e\x32-.google.protobuf.python.internal.Factory1Enum\x12\x62\n\x15nested_factory_1_enum\x18\x02 \x01(\x0e\x32\x43.google.protobuf.python.internal.Factory1Message.NestedFactory1Enum\x12h\n\x18nested_factory_1_message\x18\x03 \x01(\x0b\x32\x46.google.protobuf.python.internal.Factory1Message.NestedFactory1Message\x12\x14\n\x0cscalar_value\x18\x04 \x01(\x05\x12\x12\n\nlist_value\x18\x05 \x03(\t\x1a&\n\x15NestedFactory1Message\x12\r\n\x05value\x18\x01 \x01(\t\"P\n\x12NestedFactory1Enum\x12\x1c\n\x18NESTED_FACTORY_1_VALUE_0\x10\x00\x12\x1c\n\x18NESTED_FACTORY_1_VALUE_1\x10\x01*\t\x08\xe8\x07\x10\x80\x80\x80\x80\x02*<\n\x0c\x46\x61\x63tory1Enum\x12\x15\n\x11\x46\x41\x43TORY_1_VALUE_0\x10\x00\x12\x15\n\x11\x46\x41\x43TORY_1_VALUE_1\x10\x01' )) _FACTORY1ENUM = _descriptor.EnumDescriptor( name='Factory1Enum', full_name='google.protobuf.python.internal.Factory1Enum', filename=None, file=DESCRIPTOR, values=[ _descriptor.EnumValueDescriptor(name='FACTORY_1_VALUE_0', index=0, number=0, serialized_options=None, type=None), _descriptor.EnumValueDescriptor(name='FACTORY_1_VALUE_1', index=1, number=1, serialized_options=None, type=None), ], containing_type=None, serialized_options=None, serialized_start=553, serialized_end=613, ) _sym_db.RegisterEnumDescriptor(_FACTORY1ENUM) Factory1Enum = enum_type_wrapper.EnumTypeWrapper(_FACTORY1ENUM) FACTORY_1_VALUE_0 = 0 FACTORY_1_VALUE_1 = 1
package='', syntax='proto2', serialized_options=None, serialized_pb=_b('\n)google/protobuf/internal/no_package.proto\";\n\x10NoPackageMessage\x12\'\n\x0fno_package_enum\x18\x01 \x01(\x0e\x32\x0e.NoPackageEnum*?\n\rNoPackageEnum\x12\x16\n\x12NO_PACKAGE_VALUE_0\x10\x00\x12\x16\n\x12NO_PACKAGE_VALUE_1\x10\x01') ) _NOPACKAGEENUM = _descriptor.EnumDescriptor( name='NoPackageEnum', full_name='NoPackageEnum', filename=None, file=DESCRIPTOR, values=[ _descriptor.EnumValueDescriptor( name='NO_PACKAGE_VALUE_0', index=0, number=0, serialized_options=None, type=None), _descriptor.EnumValueDescriptor( name='NO_PACKAGE_VALUE_1', index=1, number=1, serialized_options=None, type=None), ], containing_type=None, serialized_options=None, serialized_start=106, serialized_end=169, ) _sym_db.RegisterEnumDescriptor(_NOPACKAGEENUM) NoPackageEnum = enum_type_wrapper.EnumTypeWrapper(_NOPACKAGEENUM) NO_PACKAGE_VALUE_0 = 0 NO_PACKAGE_VALUE_1 = 1
]) _IMPORTENUM = _descriptor.EnumDescriptor( name='ImportEnum', full_name='protobuf_unittest_import.ImportEnum', filename=None, file=DESCRIPTOR, values=[ _descriptor.EnumValueDescriptor(name='IMPORT_FOO', index=0, number=7, serialized_options=None, type=None), _descriptor.EnumValueDescriptor(name='IMPORT_BAR', index=1, number=8, serialized_options=None, type=None), _descriptor.EnumValueDescriptor(name='IMPORT_BAZ', index=2, number=9, serialized_options=None, type=None), ], containing_type=None, serialized_options=None, serialized_start=141, serialized_end=201, ) _sym_db.RegisterEnumDescriptor(_IMPORTENUM)