Package google :: Package protobuf :: Module descriptor_pool
[hide private]
[frames] | no frames]

Module descriptor_pool

source code

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.


Author: matthewtoia@google.com (Matt Toia)

Classes [hide private]
  DescriptorPool
A collection of protobufs dynamically constructed by descriptor protos.
Functions [hide private]
 
_Deprecated(func)
Mark functions as deprecated.
source code
 
_NormalizeFullyQualifiedName(name)
Remove leading period from fully-qualified type name.
source code
 
_OptionsOrNone(descriptor_proto)
Returns the value of the field `options`, or None if it is not set.
source code
 
_IsMessageSetExtension(field) source code
 
_PrefixWithDot(name) source code
 
Default() source code
Variables [hide private]
  _USE_C_DESCRIPTORS = False
  _DEFAULT = <google.protobuf.descriptor_pool.DescriptorPool obj...
  __package__ = 'google.protobuf'
Function Details [hide private]

_NormalizeFullyQualifiedName(name)

source code 
Remove leading period from fully-qualified type name.

Due to b/13860351 in descriptor_database.py, types in the root namespace are
generated with a leading period. This function removes that prefix.

Args:
  name: A str, the fully-qualified symbol name.

Returns:
  A str, the normalized fully-qualified symbol name.


Variables Details [hide private]

_DEFAULT

Value:
<google.protobuf.descriptor_pool.DescriptorPool object>