google.protobuf.descriptor_database

Provides a container for DescriptorProtos.

class google.protobuf.descriptor_database.DescriptorDatabase

A container accepting FileDescriptorProtos and maps DescriptorProtos.

Add(file_desc_proto)

Adds the FileDescriptorProto and its types to this database.

Parameters:

file_desc_proto – The FileDescriptorProto to add.

Raises:

DescriptorDatabaseConflictingDefinitionError – if an attempt is made to add a proto with the same name but different definition than an existing proto in the database.

FindAllExtensionNumbers(extendee_name)
FindFileByName(name)

Finds the file descriptor proto by file name.

Typically the file name is a relative path ending to a .proto file. The proto with the given name will have to have been added to this database using the Add method or else an error will be raised.

Parameters:

name – The file name to find.

Returns:

The file descriptor proto matching the name.

Raises:

KeyError if no file by the given name was added.

FindFileContainingExtension(extendee_name, extension_number)
FindFileContainingSymbol(symbol)

Finds the file descriptor proto containing the specified symbol.

The symbol should be a fully qualified name including the file descriptor’s package and any containing messages. Some examples:

‘some.package.name.Message’ ‘some.package.name.Message.NestedEnum’ ‘some.package.name.Message.some_field’

The file descriptor proto containing the specified symbol must be added to this database using the Add method or else an error will be raised.

Parameters:

symbol – The fully qualified symbol name.

Returns:

The file descriptor proto containing the symbol.

Raises:

KeyError if no file contains the specified symbol.

exception google.protobuf.descriptor_database.DescriptorDatabaseConflictingDefinitionError

Raised when a proto is added with the same name & different descriptor.

args
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception google.protobuf.descriptor_database.Error
args
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.