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

Class Descriptor

source code

       object --+        
                |        
   DescriptorBase --+    
                    |    
_NestedDescriptorBase --+
                        |
                       Descriptor

Descriptor for a protocol message type.

A Descriptor instance has the following attributes:

  name: (str) Name of this protocol message type.
  full_name: (str) Fully-qualified name of this protocol message type,
    which will include protocol "package" name and the name of any
    enclosing types.

  containing_type: (Descriptor) Reference to the descriptor of the
    type containing us, or None if this is top-level.

  fields: (list of FieldDescriptors) Field descriptors for all
    fields in this type.
  fields_by_number: (dict int -> FieldDescriptor) Same FieldDescriptor
    objects as in |fields|, but indexed by "number" attribute in each
    FieldDescriptor.
  fields_by_name: (dict str -> FieldDescriptor) Same FieldDescriptor
    objects as in |fields|, but indexed by "name" attribute in each
    FieldDescriptor.
  fields_by_camelcase_name: (dict str -> FieldDescriptor) Same
    FieldDescriptor objects as in |fields|, but indexed by
    "camelcase_name" attribute in each FieldDescriptor.

  nested_types: (list of Descriptors) Descriptor references
    for all protocol message types nested within this one.
  nested_types_by_name: (dict str -> Descriptor) Same Descriptor
    objects as in |nested_types|, but indexed by "name" attribute
    in each Descriptor.

  enum_types: (list of EnumDescriptors) EnumDescriptor references
    for all enums contained within this type.
  enum_types_by_name: (dict str ->EnumDescriptor) Same EnumDescriptor
    objects as in |enum_types|, but indexed by "name" attribute
    in each EnumDescriptor.
  enum_values_by_name: (dict str -> EnumValueDescriptor) Dict mapping
    from enum value name to EnumValueDescriptor for that value.

  extensions: (list of FieldDescriptor) All extensions defined directly
    within this message type (NOT within a nested type).
  extensions_by_name: (dict, string -> FieldDescriptor) Same FieldDescriptor
    objects as |extensions|, but indexed by "name" attribute of each
    FieldDescriptor.

  is_extendable:  Does this type define any extension ranges?

  oneofs: (list of OneofDescriptor) The list of descriptors for oneof fields
    in this message.
  oneofs_by_name: (dict str -> OneofDescriptor) Same objects as in |oneofs|,
    but indexed by "name" attribute.

  file: (FileDescriptor) Reference to file descriptor.

Instance Methods [hide private]
a new object with type S, a subtype of T
__new__(cls, name, full_name, filename, containing_type, fields, nested_types, enum_types, extensions, options=None, serialized_options=None, is_extendable=True, extension_ranges=None, oneofs=None, file=None, serialized_start=None, serialized_end=None, syntax=None) source code
 
__init__(self, name, full_name, filename, containing_type, fields, nested_types, enum_types, extensions, options=None, serialized_options=None, is_extendable=True, extension_ranges=None, oneofs=None, file=None, serialized_start=None, serialized_end=None, syntax=None)
Arguments to __init__() are as described in the description of Descriptor fields above.
source code
 
EnumValueName(self, enum, value)
Returns the string name of an enum value.
source code
 
CopyToProto(self, proto)
Copies this to a descriptor_pb2.DescriptorProto.
source code

Inherited from DescriptorBase: GetOptions

Inherited from DescriptorBase (private): _SetOptions

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Variables [hide private]
  _C_DESCRIPTOR_CLASS = _message.Descriptor
Properties [hide private]
  fields_by_camelcase_name

Inherited from object: __class__

Method Details [hide private]

__new__(cls, name, full_name, filename, containing_type, fields, nested_types, enum_types, extensions, options=None, serialized_options=None, is_extendable=True, extension_ranges=None, oneofs=None, file=None, serialized_start=None, serialized_end=None, syntax=None)

source code 
Returns: a new object with type S, a subtype of T
Overrides: object.__new__
(inherited documentation)

__init__(self, name, full_name, filename, containing_type, fields, nested_types, enum_types, extensions, options=None, serialized_options=None, is_extendable=True, extension_ranges=None, oneofs=None, file=None, serialized_start=None, serialized_end=None, syntax=None)
(Constructor)

source code 

Arguments to __init__() are as described in the description of Descriptor fields above.

Note that filename is an obsolete argument, that is not used anymore. Please use file.name to access this as an attribute.

Overrides: object.__init__

EnumValueName(self, enum, value)

source code 
Returns the string name of an enum value.

This is just a small helper method to simplify a common operation.

Args:
  enum: string name of the Enum.
  value: int, value of the enum.

Returns:
  string name of the enum value.

Raises:
  KeyError if either the Enum doesn't exist or the value is not a valid
    value for the enum.

CopyToProto(self, proto)

source code 
Copies this to a descriptor_pb2.DescriptorProto.

Args:
  proto: An empty descriptor_pb2.DescriptorProto.

Overrides: _NestedDescriptorBase.CopyToProto

Property Details [hide private]

fields_by_camelcase_name

Get Method:
unreachable.fields_by_camelcase_name(self)