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

Module descriptor

source code

Descriptors essentially contain exactly the information found in a .proto file, in types that make this information accessible in Python.


Author: robinson@google.com (Will Robinson)

Classes [hide private]
  Error
Base error for this module.
  TypeTransformationError
Error transforming between python proto type and corresponding C++ type.
  _Lock
Wrapper class of threading.Lock(), which is allowed by 'with'.
  DescriptorBase
Descriptors base class.
  _NestedDescriptorBase
Common class for descriptors that can be nested.
  Descriptor
Descriptor for a protocol message type.
  FieldDescriptor
Descriptor for a single field in a .proto file.
  EnumDescriptor
Descriptor for an enum defined in a .proto file.
  EnumValueDescriptor
Descriptor for a single value within an enum.
  OneofDescriptor
Descriptor for a oneof field.
  ServiceDescriptor
Descriptor for a service.
  MethodDescriptor
Descriptor for a method in a service.
  FileDescriptor
Descriptor for a file.
Functions [hide private]
 
_ParseOptions(message, string)
Parses serialized options.
source code
 
_ToCamelCase(name)
Converts name to camel-case and returns it.
source code
 
_OptionsOrNone(descriptor_proto)
Returns the value of the field `options`, or None if it is not set.
source code
 
_ToJsonName(name)
Converts name to Json name and returns it.
source code
 
MakeDescriptor(desc_proto, package='', build_file_if_cpp=True, syntax=None)
Make a protobuf Descriptor given a DescriptorProto protobuf.
source code
Variables [hide private]
  _USE_C_DESCRIPTORS = False
  _lock = <thread.lock object>
  __package__ = 'google.protobuf'
Function Details [hide private]

_ParseOptions(message, string)

source code 

Parses serialized options.

This helper function is used to parse serialized options in generated proto2 files. It must not be used outside proto2.

MakeDescriptor(desc_proto, package='', build_file_if_cpp=True, syntax=None)

source code 
Make a protobuf Descriptor given a DescriptorProto protobuf.

Handles nested descriptors. Note that this is limited to the scope of defining
a message inside of another message. Composite fields can currently only be
resolved if the message is defined in the same scope as the field.

Args:
  desc_proto: The descriptor_pb2.DescriptorProto protobuf message.
  package: Optional package name for the new message Descriptor (string).
  build_file_if_cpp: Update the C++ descriptor pool if api matches.
                     Set to False on recursion, so no duplicates are created.
  syntax: The syntax/semantics that should be used.  Set to "proto3" to get
          proto3 field presence semantics.
Returns:
  A Descriptor for protobuf messages.