Public Member Functions | Private Member Functions | Private Attributes | List of all members
google.protobuf.descriptor_pool.DescriptorPool Class Reference
Inheritance diagram for google.protobuf.descriptor_pool.DescriptorPool:
Inheritance graph
[legend]

Public Member Functions

def __init__ (self, descriptor_db=None)
 
def __new__ (cls, descriptor_db=None)
 
def Add (self, file_desc_proto)
 
def AddDescriptor (self, desc)
 
def AddEnumDescriptor (self, enum_desc)
 
def AddExtensionDescriptor (self, extension)
 
def AddFileDescriptor (self, file_desc)
 
def AddSerializedFile (self, serialized_file_desc_proto)
 
def AddServiceDescriptor (self, service_desc)
 
def FindAllExtensions (self, message_descriptor)
 
def FindEnumTypeByName (self, full_name)
 
def FindExtensionByName (self, full_name)
 
def FindExtensionByNumber (self, message_descriptor, number)
 
def FindFieldByName (self, full_name)
 
def FindFileByName (self, file_name)
 
def FindFileContainingSymbol (self, symbol)
 
def FindMessageTypeByName (self, full_name)
 
def FindMethodByName (self, full_name)
 
def FindOneofByName (self, full_name)
 
def FindServiceByName (self, full_name)
 

Private Member Functions

def _AddFileDescriptor (self, file_desc)
 
def _CheckConflictRegister (self, desc, desc_name, file_name)
 
def _ConvertEnumDescriptor (self, enum_proto, package=None, file_desc=None, containing_type=None, scope=None, top_level=False)
 
def _ConvertFileProtoToFileDescriptor (self, file_proto)
 
def _ConvertMessageDescriptor (self, desc_proto, package=None, file_desc=None, scope=None, syntax=None)
 
def _ExtractSymbols (self, descriptors)
 
def _FindFileContainingSymbolInDb (self, symbol)
 
def _GetDeps (self, dependencies)
 
def _GetTypeFromScope (self, package, type_name, scope)
 
def _InternalFindFileContainingSymbol (self, symbol)
 
def _MakeEnumValueDescriptor (self, value_proto, index)
 
def _MakeFieldDescriptor (self, field_proto, message_name, index, file_desc, is_extension=False)
 
def _MakeMethodDescriptor (self, method_proto, service_name, package, scope, index)
 
def _MakeServiceDescriptor (self, service_proto, service_index, scope, package, file_desc)
 
def _SetAllFieldTypes (self, package, desc_proto, scope)
 
def _SetFieldType (self, field_proto, field_desc, package, scope)
 
def _TryLoadExtensionFromDB (self, message_descriptor, number)
 

Private Attributes

 _descriptor_db
 
 _descriptors
 
 _enum_descriptors
 
 _extensions_by_name
 
 _extensions_by_number
 
 _file_desc_by_toplevel_extension
 
 _file_descriptors
 
 _internal_db
 
 _service_descriptors
 
 _top_enum_values
 
 _toplevel_extensions
 

Detailed Description

A collection of protobufs dynamically constructed by descriptor protos.

Definition at line 102 of file descriptor_pool.py.

Constructor & Destructor Documentation

◆ __init__()

def google.protobuf.descriptor_pool.DescriptorPool.__init__ (   self,
  descriptor_db = None 
)
Initializes a Pool of proto buffs.

The descriptor_db argument to the constructor is provided to allow
specialized file descriptor proto lookup code to be triggered on demand. An
example would be an implementation which will read and compile a file
specified in a call to FindFileByName() and not require the call to Add()
at all. Results from this database will be cached internally here as well.

Args:
  descriptor_db: A secondary source of file descriptors.

Definition at line 111 of file descriptor_pool.py.

Member Function Documentation

◆ __new__()

def google.protobuf.descriptor_pool.DescriptorPool.__new__ (   cls,
  descriptor_db = None 
)

Definition at line 107 of file descriptor_pool.py.

◆ _AddFileDescriptor()

def google.protobuf.descriptor_pool.DescriptorPool._AddFileDescriptor (   self,
  file_desc 
)
private
Adds a FileDescriptor to the pool, non-recursively.

If the FileDescriptor contains messages or enums, the caller must explicitly
register them.

Args:
  file_desc: A FileDescriptor.

Definition at line 328 of file descriptor_pool.py.

◆ _CheckConflictRegister()

def google.protobuf.descriptor_pool.DescriptorPool._CheckConflictRegister (   self,
  desc,
  desc_name,
  file_name 
)
private
Check if the descriptor name conflicts with another of the same name.

Args:
  desc: Descriptor of a message, enum, service, extension or enum value.
  desc_name: the full name of desc.
  file_name: The file name of descriptor.

Definition at line 141 of file descriptor_pool.py.

◆ _ConvertEnumDescriptor()

def google.protobuf.descriptor_pool.DescriptorPool._ConvertEnumDescriptor (   self,
  enum_proto,
  package = None,
  file_desc = None,
  containing_type = None,
  scope = None,
  top_level = False 
)
private
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.
  top_level: If True, the enum is a top level symbol. If False, the enum
  is defined inside a message.

Returns:
  The added descriptor

Definition at line 857 of file descriptor_pool.py.

◆ _ConvertFileProtoToFileDescriptor()

def google.protobuf.descriptor_pool.DescriptorPool._ConvertFileProtoToFileDescriptor (   self,
  file_proto 
)
private
Creates a FileDescriptor from a proto or returns a cached copy.

This method also has the side effect of loading all the symbols found in
the file into the appropriate dictionaries in the pool.

Args:
  file_proto: The proto to convert.

Returns:
  A FileDescriptor matching the passed in proto.

Definition at line 688 of file descriptor_pool.py.

◆ _ConvertMessageDescriptor()

def google.protobuf.descriptor_pool.DescriptorPool._ConvertMessageDescriptor (   self,
  desc_proto,
  package = None,
  file_desc = None,
  scope = None,
  syntax = None 
)
private
Adds the proto to the pool in the specified package.

Args:
  desc_proto: The descriptor_pb2.DescriptorProto protobuf message.
  package: The package the proto should be located in.
  file_desc: The file containing this message.
  scope: Dict mapping short and full symbols to message and enum types.
  syntax: string indicating syntax of the file ("proto2" or "proto3")

Returns:
  The added descriptor.

Definition at line 774 of file descriptor_pool.py.

◆ _ExtractSymbols()

def google.protobuf.descriptor_pool.DescriptorPool._ExtractSymbols (   self,
  descriptors 
)
private
Pulls out all the symbols from descriptor protos.

Args:
  descriptors: The messages to extract descriptors from.
Yields:
  A two element tuple of the type name and descriptor object.

Definition at line 1135 of file descriptor_pool.py.

◆ _FindFileContainingSymbolInDb()

def google.protobuf.descriptor_pool.DescriptorPool._FindFileContainingSymbolInDb (   self,
  symbol 
)
private
Finds the file in descriptor DB containing the specified symbol.

Args:
  symbol: The name of the symbol to search for.

Returns:
  A FileDescriptor that contains the specified symbol.

Raises:
  KeyError: if the file cannot be found in the descriptor database.

Definition at line 665 of file descriptor_pool.py.

◆ _GetDeps()

def google.protobuf.descriptor_pool.DescriptorPool._GetDeps (   self,
  dependencies 
)
private
Recursively finds dependencies for file protos.

Args:
  dependencies: The names of the files being depended on.

Yields:
  Each direct and indirect dependency.

Definition at line 1151 of file descriptor_pool.py.

◆ _GetTypeFromScope()

def google.protobuf.descriptor_pool.DescriptorPool._GetTypeFromScope (   self,
  package,
  type_name,
  scope 
)
private
Finds a given type name in the current scope.

Args:
  package: The package the proto should be located in.
  type_name: The name of the type to be found in the scope.
  scope: Dict mapping short and full symbols to message and enum types.

Returns:
  The descriptor for the requested type.

Definition at line 1167 of file descriptor_pool.py.

◆ _InternalFindFileContainingSymbol()

def google.protobuf.descriptor_pool.DescriptorPool._InternalFindFileContainingSymbol (   self,
  symbol 
)
private
Gets the already built FileDescriptor containing the specified symbol.

Args:
  symbol: The name of the symbol to search for.

Returns:
  A FileDescriptor that contains the specified symbol.

Raises:
  KeyError: if the file cannot be found in the pool.

Definition at line 397 of file descriptor_pool.py.

◆ _MakeEnumValueDescriptor()

def google.protobuf.descriptor_pool.DescriptorPool._MakeEnumValueDescriptor (   self,
  value_proto,
  index 
)
private
Creates a enum value descriptor object from a enum value proto.

Args:
  value_proto: The proto describing the enum value.
  index: The index of the enum value.

Returns:
  An initialized EnumValueDescriptor object.

Definition at line 1057 of file descriptor_pool.py.

◆ _MakeFieldDescriptor()

def google.protobuf.descriptor_pool.DescriptorPool._MakeFieldDescriptor (   self,
  field_proto,
  message_name,
  index,
  file_desc,
  is_extension = False 
)
private
Creates a field descriptor from a FieldDescriptorProto.

For message and enum type fields, this method will do a look up
in the pool for the appropriate descriptor for that type. If it
is unavailable, it will fall back to the _source function to
create it. If this type is still unavailable, construction will
fail.

Args:
  field_proto: The proto describing the field.
  message_name: The name of the containing message.
  index: Index of the field
  file_desc: The file containing the field descriptor.
  is_extension: Indication that this field is for an extension.

Returns:
  An initialized FieldDescriptor object

Definition at line 907 of file descriptor_pool.py.

◆ _MakeMethodDescriptor()

def google.protobuf.descriptor_pool.DescriptorPool._MakeMethodDescriptor (   self,
  method_proto,
  service_name,
  package,
  scope,
  index 
)
private
Creates a method descriptor from a MethodDescriptorProto.

Args:
  method_proto: The proto describing the method.
  service_name: The name of the containing service.
  package: Optional package name to look up for types.
  scope: Scope containing available types.
  index: Index of the method in the service.

Returns:
  An initialized MethodDescriptor object.

Definition at line 1108 of file descriptor_pool.py.

◆ _MakeServiceDescriptor()

def google.protobuf.descriptor_pool.DescriptorPool._MakeServiceDescriptor (   self,
  service_proto,
  service_index,
  scope,
  package,
  file_desc 
)
private
Make a protobuf ServiceDescriptor given a ServiceDescriptorProto.

Args:
  service_proto: The descriptor_pb2.ServiceDescriptorProto protobuf message.
  service_index: The index of the service in the File.
  scope: Dict mapping short and full symbols to message and enum types.
  package: Optional package name for the new message EnumDescriptor.
  file_desc: The file containing the service descriptor.

Returns:
  The added descriptor.

Definition at line 1075 of file descriptor_pool.py.

◆ _SetAllFieldTypes()

def google.protobuf.descriptor_pool.DescriptorPool._SetAllFieldTypes (   self,
  package,
  desc_proto,
  scope 
)
private
Sets all the descriptor's fields's types.

This method also sets the containing types on any extensions.

Args:
  package: The current package of desc_proto.
  desc_proto: The message descriptor to update.
  scope: Enclosing scope of available types.

Definition at line 951 of file descriptor_pool.py.

◆ _SetFieldType()

def google.protobuf.descriptor_pool.DescriptorPool._SetFieldType (   self,
  field_proto,
  field_desc,
  package,
  scope 
)
private
Sets the field's type, cpp_type, message_type and enum_type.

Args:
  field_proto: Data about the field in proto format.
  field_desc: The descriptor to modiy.
  package: The package the field's container is in.
  scope: Enclosing scope of available types.

Definition at line 983 of file descriptor_pool.py.

◆ _TryLoadExtensionFromDB()

def google.protobuf.descriptor_pool.DescriptorPool._TryLoadExtensionFromDB (   self,
  message_descriptor,
  number 
)
private
Try to Load extensions from decriptor db.

Args:
  message_descriptor: descriptor of the extended message.
  number: the extension number that needs to be loaded.

Definition at line 592 of file descriptor_pool.py.

◆ Add()

def google.protobuf.descriptor_pool.DescriptorPool.Add (   self,
  file_desc_proto 
)
Adds the FileDescriptorProto and its types to this pool.

Args:
  file_desc_proto: The FileDescriptorProto to add.

Definition at line 179 of file descriptor_pool.py.

◆ AddDescriptor()

def google.protobuf.descriptor_pool.DescriptorPool.AddDescriptor (   self,
  desc 
)
Adds a Descriptor to the pool, non-recursively.

If the Descriptor contains nested messages or enums, the caller must
explicitly register them. This method also registers the FileDescriptor
associated with the message.

Args:
  desc: A Descriptor.

Definition at line 202 of file descriptor_pool.py.

◆ AddEnumDescriptor()

def google.protobuf.descriptor_pool.DescriptorPool.AddEnumDescriptor (   self,
  enum_desc 
)
Adds an EnumDescriptor to the pool.

This method also registers the FileDescriptor associated with the enum.

Args:
  enum_desc: An EnumDescriptor.

Definition at line 220 of file descriptor_pool.py.

◆ AddExtensionDescriptor()

def google.protobuf.descriptor_pool.DescriptorPool.AddExtensionDescriptor (   self,
  extension 
)
Adds a FieldDescriptor describing an extension to the pool.

Args:
  extension: A FieldDescriptor.

Raises:
  AssertionError: when another extension with the same number extends the
same message.
  TypeError: when the specified extension is not a
descriptor.FieldDescriptor.

Definition at line 268 of file descriptor_pool.py.

◆ AddFileDescriptor()

def google.protobuf.descriptor_pool.DescriptorPool.AddFileDescriptor (   self,
  file_desc 
)
Adds a FileDescriptor to the pool, non-recursively.

If the FileDescriptor contains messages or enums, the caller must explicitly
register them.

Args:
  file_desc: A FileDescriptor.

Definition at line 310 of file descriptor_pool.py.

◆ AddSerializedFile()

def google.protobuf.descriptor_pool.DescriptorPool.AddSerializedFile (   self,
  serialized_file_desc_proto 
)
Adds the FileDescriptorProto and its types to this pool.

Args:
  serialized_file_desc_proto: A bytes string, serialization of the
FileDescriptorProto to add.

Definition at line 188 of file descriptor_pool.py.

◆ AddServiceDescriptor()

def google.protobuf.descriptor_pool.DescriptorPool.AddServiceDescriptor (   self,
  service_desc 
)
Adds a ServiceDescriptor to the pool.

Args:
  service_desc: A ServiceDescriptor.

Definition at line 254 of file descriptor_pool.py.

◆ FindAllExtensions()

def google.protobuf.descriptor_pool.DescriptorPool.FindAllExtensions (   self,
  message_descriptor 
)
Gets all the known extension of a given message.

Extensions have to be registered to this pool by calling
AddExtensionDescriptor.

Args:
  message_descriptor: descriptor of the extended message.

Returns:
  A list of FieldDescriptor describing the extensions.

Definition at line 568 of file descriptor_pool.py.

◆ FindEnumTypeByName()

def google.protobuf.descriptor_pool.DescriptorPool.FindEnumTypeByName (   self,
  full_name 
)
Loads the named enum descriptor from the pool.

Args:
  full_name: The full name of the enum descriptor to load.

Returns:
  The enum descriptor for the named type.

Raises:
  KeyError: if the enum cannot be found in the pool.

Definition at line 463 of file descriptor_pool.py.

◆ FindExtensionByName()

def google.protobuf.descriptor_pool.DescriptorPool.FindExtensionByName (   self,
  full_name 
)
Loads the named extension descriptor from the pool.

Args:
  full_name: The full name of the extension descriptor to load.

Returns:
  A FieldDescriptor, describing the named extension.

Raises:
  KeyError: if the extension cannot be found in the pool.

Definition at line 515 of file descriptor_pool.py.

◆ FindExtensionByNumber()

def google.protobuf.descriptor_pool.DescriptorPool.FindExtensionByNumber (   self,
  message_descriptor,
  number 
)
Gets the extension of the specified message with the specified number.

Extensions have to be registered to this pool by calling
AddExtensionDescriptor.

Args:
  message_descriptor: descriptor of the extended message.
  number: integer, number of the extension field.

Returns:
  A FieldDescriptor describing the extension.

Raises:
  KeyError: when no extension with the given number is known for the
specified message.

Definition at line 545 of file descriptor_pool.py.

◆ FindFieldByName()

def google.protobuf.descriptor_pool.DescriptorPool.FindFieldByName (   self,
  full_name 
)
Loads the named field descriptor from the pool.

Args:
  full_name: The full name of the field descriptor to load.

Returns:
  The field descriptor for the named field.

Raises:
  KeyError: if the field cannot be found in the pool.

Definition at line 481 of file descriptor_pool.py.

◆ FindFileByName()

def google.protobuf.descriptor_pool.DescriptorPool.FindFileByName (   self,
  file_name 
)
Gets a FileDescriptor by file name.

Args:
  file_name: The path to the file to get a descriptor for.

Returns:
  A FileDescriptor for the named file.

Raises:
  KeyError: if the file cannot be found in the pool.

Definition at line 342 of file descriptor_pool.py.

◆ FindFileContainingSymbol()

def google.protobuf.descriptor_pool.DescriptorPool.FindFileContainingSymbol (   self,
  symbol 
)
Gets the FileDescriptor for the file containing the specified symbol.

Args:
  symbol: The name of the symbol to search for.

Returns:
  A FileDescriptor that contains the specified symbol.

Raises:
  KeyError: if the file cannot be found in the pool.

Definition at line 371 of file descriptor_pool.py.

◆ FindMessageTypeByName()

def google.protobuf.descriptor_pool.DescriptorPool.FindMessageTypeByName (   self,
  full_name 
)
Loads the named descriptor from the pool.

Args:
  full_name: The full name of the descriptor to load.

Returns:
  The descriptor for the named type.

Raises:
  KeyError: if the message cannot be found in the pool.

Definition at line 445 of file descriptor_pool.py.

◆ FindMethodByName()

def google.protobuf.descriptor_pool.DescriptorPool.FindMethodByName (   self,
  full_name 
)
Loads the named service method descriptor from the pool.

Args:
  full_name: The full name of the method descriptor to load.

Returns:
  The method descriptor for the service method.

Raises:
  KeyError: if the method cannot be found in the pool.

Definition at line 648 of file descriptor_pool.py.

◆ FindOneofByName()

def google.protobuf.descriptor_pool.DescriptorPool.FindOneofByName (   self,
  full_name 
)
Loads the named oneof descriptor from the pool.

Args:
  full_name: The full name of the oneof descriptor to load.

Returns:
  The oneof descriptor for the named oneof.

Raises:
  KeyError: if the oneof cannot be found in the pool.

Definition at line 498 of file descriptor_pool.py.

◆ FindServiceByName()

def google.protobuf.descriptor_pool.DescriptorPool.FindServiceByName (   self,
  full_name 
)
Loads the named service descriptor from the pool.

Args:
  full_name: The full name of the service descriptor to load.

Returns:
  The service descriptor for the named service.

Raises:
  KeyError: if the service cannot be found in the pool.

Definition at line 631 of file descriptor_pool.py.

Member Data Documentation

◆ _descriptor_db

google.protobuf.descriptor_pool.DescriptorPool._descriptor_db
private

Definition at line 125 of file descriptor_pool.py.

◆ _descriptors

google.protobuf.descriptor_pool.DescriptorPool._descriptors
private

Definition at line 126 of file descriptor_pool.py.

◆ _enum_descriptors

google.protobuf.descriptor_pool.DescriptorPool._enum_descriptors
private

Definition at line 127 of file descriptor_pool.py.

◆ _extensions_by_name

google.protobuf.descriptor_pool.DescriptorPool._extensions_by_name
private

Definition at line 138 of file descriptor_pool.py.

◆ _extensions_by_number

google.protobuf.descriptor_pool.DescriptorPool._extensions_by_number
private

Definition at line 139 of file descriptor_pool.py.

◆ _file_desc_by_toplevel_extension

google.protobuf.descriptor_pool.DescriptorPool._file_desc_by_toplevel_extension
private

Definition at line 133 of file descriptor_pool.py.

◆ _file_descriptors

google.protobuf.descriptor_pool.DescriptorPool._file_descriptors
private

Definition at line 129 of file descriptor_pool.py.

◆ _internal_db

google.protobuf.descriptor_pool.DescriptorPool._internal_db
private

Definition at line 124 of file descriptor_pool.py.

◆ _service_descriptors

google.protobuf.descriptor_pool.DescriptorPool._service_descriptors
private

Definition at line 128 of file descriptor_pool.py.

◆ _top_enum_values

google.protobuf.descriptor_pool.DescriptorPool._top_enum_values
private

Definition at line 134 of file descriptor_pool.py.

◆ _toplevel_extensions

google.protobuf.descriptor_pool.DescriptorPool._toplevel_extensions
private

Definition at line 130 of file descriptor_pool.py.


The documentation for this class was generated from the following file:


libaditof
Author(s):
autogenerated on Wed May 21 2025 02:07:09