Provides DescriptorPool to use as a container for proto2 descriptors.
The DescriptorPool is used in conjection with a DescriptorDatabase to maintain a collection of protocol buffer descriptors for use when dynamically creating message types at runtime.
For most applications protocol buffers should be used via modules generated by the protocol buffer compiler tool. This should only be used when the type of protocol buffers used in an application or library cannot be predetermined.
Below is a straightforward example on how to use this class:
pool = DescriptorPool() file_descriptor_protos = [ ... ] for file_descriptor_proto in file_descriptor_protos: pool.Add(file_descriptor_proto) my_message_descriptor = pool.FindMessageTypeByName('some.package.MessageType')
The message descriptor can be used in conjunction with the message_factory module in order to create a protocol buffer class that can be encoded and decoded.
If you want to get a Python class for the specified proto, use the helper functions inside google.protobuf.message_factory directly instead of this class.
google.protobuf.descriptor_pool.
Default
()¶
google.protobuf.descriptor_pool.
DescriptorPool
(descriptor_db=None)¶
A collection of protobufs dynamically constructed by descriptor protos.
Add
(file_desc_proto)¶
Adds the FileDescriptorProto and its types to this pool.
file_desc_proto (FileDescriptorProto) – The file descriptor to add.
AddDescriptor
(**kwargs)¶
AddEnumDescriptor
(**kwargs)¶
AddExtensionDescriptor
(**kwargs)¶
AddFileDescriptor
(**kwargs)¶
AddSerializedFile
(serialized_file_desc_proto)¶
Adds the FileDescriptorProto and its types to this pool.
serialized_file_desc_proto (bytes) – A bytes string, serialization of the FileDescriptorProto
to add.
Descriptor for the added file.
AddServiceDescriptor
(**kwargs)¶
FindAllExtensions
(message_descriptor)¶
Gets all the known extensions of a given message.
Extensions have to be registered to this pool by build related Add()
or AddExtensionDescriptor()
.
message_descriptor (Descriptor) – Descriptor of the extended message.
Field descriptors describing the extensions.
FindEnumTypeByName
(full_name)¶
Loads the named enum descriptor from the pool.
FindExtensionByName
(full_name)¶
Loads the named extension descriptor from the pool.
FindExtensionByNumber
(message_descriptor, number)¶
Gets the extension of the specified message with the specified number.
Extensions have to be registered to this pool by calling Add()
or AddExtensionDescriptor()
.
message_descriptor (Descriptor) – descriptor of the extended message.
number (int) – Number of the extension field.
The descriptor for the extension.
KeyError – when no extension with the given number is known for the specified message.
FindFieldByName
(full_name)¶
Loads the named field descriptor from the pool.
FindFileByName
(file_name)¶
Gets a FileDescriptor by file name.
FindFileContainingSymbol
(symbol)¶
Gets the FileDescriptor for the file containing the specified symbol.
FindMessageTypeByName
(full_name)¶
Loads the named descriptor from the pool.
FindMethodByName
(full_name)¶
Loads the named service method descriptor from the pool.
FindOneofByName
(full_name)¶
Loads the named oneof descriptor from the pool.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4