|
@@ -173,13 +173,12 @@ class _NestedDescriptorBase(DescriptorBase):
|
|
Args:
|
|
Args:
|
|
options: Protocol message options or None
|
|
options: Protocol message options or None
|
|
to use default message options.
|
|
to use default message options.
|
|
- options_class_name: (str) The class name of the above options.
|
|
|
|
-
|
|
|
|
- name: (str) Name of this protocol message type.
|
|
|
|
- full_name: (str) Fully-qualified name of this protocol message type,
|
|
|
|
|
|
+ options_class_name (str): The class name of the above options.
|
|
|
|
+ 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
|
|
which will include protocol "package" name and the name of any
|
|
enclosing types.
|
|
enclosing types.
|
|
- file: (FileDescriptor) Reference to file info.
|
|
|
|
|
|
+ file (FileDescriptor): Reference to file info.
|
|
containing_type: if provided, this is a nested descriptor, with this
|
|
containing_type: if provided, this is a nested descriptor, with this
|
|
descriptor as parent, otherwise None.
|
|
descriptor as parent, otherwise None.
|
|
serialized_start: The start index (inclusive) in block in the
|
|
serialized_start: The start index (inclusive) in block in the
|
|
@@ -223,56 +222,45 @@ class Descriptor(_NestedDescriptorBase):
|
|
|
|
|
|
"""Descriptor for a protocol message type.
|
|
"""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.
|
|
|
|
|
|
+ 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[FieldDescriptor]): Field descriptors for all fields in
|
|
|
|
+ this type.
|
|
|
|
+ fields_by_number (dict(int, FieldDescriptor)): Same
|
|
|
|
+ :class:`FieldDescriptor` objects as in :attr:`fields`, but indexed
|
|
|
|
+ by "number" attribute in each FieldDescriptor.
|
|
|
|
+ fields_by_name (dict(str, FieldDescriptor)): Same
|
|
|
|
+ :class:`FieldDescriptor` objects as in :attr:`fields`, but indexed by
|
|
|
|
+ "name" attribute in each :class:`FieldDescriptor`.
|
|
|
|
+ nested_types (list[Descriptor]): Descriptor references
|
|
|
|
+ for all protocol message types nested within this one.
|
|
|
|
+ nested_types_by_name (dict(str, Descriptor)): Same Descriptor
|
|
|
|
+ objects as in :attr:`nested_types`, but indexed by "name" attribute
|
|
|
|
+ in each Descriptor.
|
|
|
|
+ enum_types (list[EnumDescriptor]): :class:`EnumDescriptor` references
|
|
|
|
+ for all enums contained within this type.
|
|
|
|
+ enum_types_by_name (dict(str, EnumDescriptor)): Same
|
|
|
|
+ :class:`EnumDescriptor` objects as in :attr:`enum_types`, but
|
|
|
|
+ indexed by "name" attribute in each EnumDescriptor.
|
|
|
|
+ enum_values_by_name (dict(str, EnumValueDescriptor)): Dict mapping
|
|
|
|
+ from enum value name to :class:`EnumValueDescriptor` for that value.
|
|
|
|
+ extensions (list[FieldDescriptor]): All extensions defined directly
|
|
|
|
+ within this message type (NOT within a nested type).
|
|
|
|
+ extensions_by_name (dict(str, FieldDescriptor)): Same FieldDescriptor
|
|
|
|
+ objects as :attr:`extensions`, but indexed by "name" attribute of each
|
|
|
|
+ FieldDescriptor.
|
|
|
|
+ is_extendable (bool): Does this type define any extension ranges?
|
|
|
|
+ oneofs (list[OneofDescriptor]): The list of descriptors for oneof fields
|
|
|
|
+ in this message.
|
|
|
|
+ oneofs_by_name (dict(str, OneofDescriptor)): Same objects as in
|
|
|
|
+ :attr:`oneofs`, but indexed by "name" attribute.
|
|
|
|
+ file (FileDescriptor): Reference to file descriptor.
|
|
|
|
+
|
|
"""
|
|
"""
|
|
|
|
|
|
if _USE_C_DESCRIPTORS:
|
|
if _USE_C_DESCRIPTORS:
|
|
@@ -345,6 +333,9 @@ class Descriptor(_NestedDescriptorBase):
|
|
|
|
|
|
@property
|
|
@property
|
|
def fields_by_camelcase_name(self):
|
|
def fields_by_camelcase_name(self):
|
|
|
|
+ """Same FieldDescriptor objects as in :attr:`fields`, but indexed by
|
|
|
|
+ :attr:`FieldDescriptor.camelcase_name`.
|
|
|
|
+ """
|
|
if self._fields_by_camelcase_name is None:
|
|
if self._fields_by_camelcase_name is None:
|
|
self._fields_by_camelcase_name = dict(
|
|
self._fields_by_camelcase_name = dict(
|
|
(f.camelcase_name, f) for f in self.fields)
|
|
(f.camelcase_name, f) for f in self.fields)
|
|
@@ -393,53 +384,51 @@ class FieldDescriptor(DescriptorBase):
|
|
|
|
|
|
"""Descriptor for a single field in a .proto file.
|
|
"""Descriptor for a single field in a .proto file.
|
|
|
|
|
|
- A FieldDescriptor instance has the following attributes:
|
|
|
|
-
|
|
|
|
- name: (str) Name of this field, exactly as it appears in .proto.
|
|
|
|
- full_name: (str) Name of this field, including containing scope. This is
|
|
|
|
|
|
+ Attributes:
|
|
|
|
+ name (str): Name of this field, exactly as it appears in .proto.
|
|
|
|
+ full_name (str): Name of this field, including containing scope. This is
|
|
particularly relevant for extensions.
|
|
particularly relevant for extensions.
|
|
- camelcase_name: (str) Camelcase name of this field.
|
|
|
|
- index: (int) Dense, 0-indexed index giving the order that this
|
|
|
|
|
|
+ index (int): Dense, 0-indexed index giving the order that this
|
|
field textually appears within its message in the .proto file.
|
|
field textually appears within its message in the .proto file.
|
|
- number: (int) Tag number declared for this field in the .proto file.
|
|
|
|
|
|
+ number (int): Tag number declared for this field in the .proto file.
|
|
|
|
|
|
- type: (One of the TYPE_* constants below) Declared type.
|
|
|
|
- cpp_type: (One of the CPPTYPE_* constants below) C++ type used to
|
|
|
|
|
|
+ type (int): (One of the TYPE_* constants below) Declared type.
|
|
|
|
+ cpp_type (int): (One of the CPPTYPE_* constants below) C++ type used to
|
|
represent this field.
|
|
represent this field.
|
|
|
|
|
|
- label: (One of the LABEL_* constants below) Tells whether this
|
|
|
|
|
|
+ label (int): (One of the LABEL_* constants below) Tells whether this
|
|
field is optional, required, or repeated.
|
|
field is optional, required, or repeated.
|
|
- has_default_value: (bool) True if this field has a default value defined,
|
|
|
|
|
|
+ has_default_value (bool): True if this field has a default value defined,
|
|
otherwise false.
|
|
otherwise false.
|
|
- default_value: (Varies) Default value of this field. Only
|
|
|
|
|
|
+ default_value (Varies): Default value of this field. Only
|
|
meaningful for non-repeated scalar fields. Repeated fields
|
|
meaningful for non-repeated scalar fields. Repeated fields
|
|
should always set this to [], and non-repeated composite
|
|
should always set this to [], and non-repeated composite
|
|
fields should always set this to None.
|
|
fields should always set this to None.
|
|
|
|
|
|
- containing_type: (Descriptor) Descriptor of the protocol message
|
|
|
|
|
|
+ containing_type (Descriptor): Descriptor of the protocol message
|
|
type that contains this field. Set by the Descriptor constructor
|
|
type that contains this field. Set by the Descriptor constructor
|
|
if we're passed into one.
|
|
if we're passed into one.
|
|
Somewhat confusingly, for extension fields, this is the
|
|
Somewhat confusingly, for extension fields, this is the
|
|
descriptor of the EXTENDED message, not the descriptor
|
|
descriptor of the EXTENDED message, not the descriptor
|
|
of the message containing this field. (See is_extension and
|
|
of the message containing this field. (See is_extension and
|
|
extension_scope below).
|
|
extension_scope below).
|
|
- message_type: (Descriptor) If a composite field, a descriptor
|
|
|
|
|
|
+ message_type (Descriptor): If a composite field, a descriptor
|
|
of the message type contained in this field. Otherwise, this is None.
|
|
of the message type contained in this field. Otherwise, this is None.
|
|
- enum_type: (EnumDescriptor) If this field contains an enum, a
|
|
|
|
|
|
+ enum_type (EnumDescriptor): If this field contains an enum, a
|
|
descriptor of that enum. Otherwise, this is None.
|
|
descriptor of that enum. Otherwise, this is None.
|
|
|
|
|
|
is_extension: True iff this describes an extension field.
|
|
is_extension: True iff this describes an extension field.
|
|
- extension_scope: (Descriptor) Only meaningful if is_extension is True.
|
|
|
|
|
|
+ extension_scope (Descriptor): Only meaningful if is_extension is True.
|
|
Gives the message that immediately contains this extension field.
|
|
Gives the message that immediately contains this extension field.
|
|
Will be None iff we're a top-level (file-level) extension field.
|
|
Will be None iff we're a top-level (file-level) extension field.
|
|
|
|
|
|
- options: (descriptor_pb2.FieldOptions) Protocol message field options or
|
|
|
|
|
|
+ options (descriptor_pb2.FieldOptions): Protocol message field options or
|
|
None to use default field options.
|
|
None to use default field options.
|
|
|
|
|
|
- containing_oneof: (OneofDescriptor) If the field is a member of a oneof
|
|
|
|
|
|
+ containing_oneof (OneofDescriptor): If the field is a member of a oneof
|
|
union, contains its descriptor. Otherwise, None.
|
|
union, contains its descriptor. Otherwise, None.
|
|
|
|
|
|
- file: (FileDescriptor) Reference to file descriptor.
|
|
|
|
|
|
+ file (FileDescriptor): Reference to file descriptor.
|
|
"""
|
|
"""
|
|
|
|
|
|
# Must be consistent with C++ FieldDescriptor::Type enum in
|
|
# Must be consistent with C++ FieldDescriptor::Type enum in
|
|
@@ -579,6 +568,11 @@ class FieldDescriptor(DescriptorBase):
|
|
|
|
|
|
@property
|
|
@property
|
|
def camelcase_name(self):
|
|
def camelcase_name(self):
|
|
|
|
+ """Camelcase name of this field.
|
|
|
|
+
|
|
|
|
+ Returns:
|
|
|
|
+ str: the name in CamelCase.
|
|
|
|
+ """
|
|
if self._camelcase_name is None:
|
|
if self._camelcase_name is None:
|
|
self._camelcase_name = _ToCamelCase(self.name)
|
|
self._camelcase_name = _ToCamelCase(self.name)
|
|
return self._camelcase_name
|
|
return self._camelcase_name
|
|
@@ -594,7 +588,7 @@ class FieldDescriptor(DescriptorBase):
|
|
Args:
|
|
Args:
|
|
proto_type: the Python proto type (descriptor.FieldDescriptor.TYPE_*)
|
|
proto_type: the Python proto type (descriptor.FieldDescriptor.TYPE_*)
|
|
Returns:
|
|
Returns:
|
|
- descriptor.FieldDescriptor.CPPTYPE_*, the C++ type.
|
|
|
|
|
|
+ int: descriptor.FieldDescriptor.CPPTYPE_*, the C++ type.
|
|
Raises:
|
|
Raises:
|
|
TypeTransformationError: when the Python proto type isn't known.
|
|
TypeTransformationError: when the Python proto type isn't known.
|
|
"""
|
|
"""
|
|
@@ -608,24 +602,23 @@ class EnumDescriptor(_NestedDescriptorBase):
|
|
|
|
|
|
"""Descriptor for an enum defined in a .proto file.
|
|
"""Descriptor for an enum defined in a .proto file.
|
|
|
|
|
|
- An EnumDescriptor instance has the following attributes:
|
|
|
|
-
|
|
|
|
- name: (str) Name of the enum type.
|
|
|
|
- full_name: (str) Full name of the type, including package name
|
|
|
|
|
|
+ Attributes:
|
|
|
|
+ name (str): Name of the enum type.
|
|
|
|
+ full_name (str): Full name of the type, including package name
|
|
and any enclosing type(s).
|
|
and any enclosing type(s).
|
|
|
|
|
|
- values: (list of EnumValueDescriptors) List of the values
|
|
|
|
|
|
+ values (list[EnumValueDescriptors]): List of the values
|
|
in this enum.
|
|
in this enum.
|
|
- values_by_name: (dict str -> EnumValueDescriptor) Same as |values|,
|
|
|
|
|
|
+ values_by_name (dict(str, EnumValueDescriptor)): Same as :attr:`values`,
|
|
but indexed by the "name" field of each EnumValueDescriptor.
|
|
but indexed by the "name" field of each EnumValueDescriptor.
|
|
- values_by_number: (dict int -> EnumValueDescriptor) Same as |values|,
|
|
|
|
|
|
+ values_by_number (dict(int, EnumValueDescriptor)): Same as :attr:`values`,
|
|
but indexed by the "number" field of each EnumValueDescriptor.
|
|
but indexed by the "number" field of each EnumValueDescriptor.
|
|
- containing_type: (Descriptor) Descriptor of the immediate containing
|
|
|
|
|
|
+ containing_type (Descriptor): Descriptor of the immediate containing
|
|
type of this enum, or None if this is an enum defined at the
|
|
type of this enum, or None if this is an enum defined at the
|
|
top level in a .proto file. Set by Descriptor's constructor
|
|
top level in a .proto file. Set by Descriptor's constructor
|
|
if we're passed into one.
|
|
if we're passed into one.
|
|
- file: (FileDescriptor) Reference to file descriptor.
|
|
|
|
- options: (descriptor_pb2.EnumOptions) Enum options message or
|
|
|
|
|
|
+ file (FileDescriptor): Reference to file descriptor.
|
|
|
|
+ options (descriptor_pb2.EnumOptions): Enum options message or
|
|
None to use default enum options.
|
|
None to use default enum options.
|
|
"""
|
|
"""
|
|
|
|
|
|
@@ -664,7 +657,7 @@ class EnumDescriptor(_NestedDescriptorBase):
|
|
"""Copies this to a descriptor_pb2.EnumDescriptorProto.
|
|
"""Copies this to a descriptor_pb2.EnumDescriptorProto.
|
|
|
|
|
|
Args:
|
|
Args:
|
|
- proto: An empty descriptor_pb2.EnumDescriptorProto.
|
|
|
|
|
|
+ proto (descriptor_pb2.EnumDescriptorProto): An empty descriptor proto.
|
|
"""
|
|
"""
|
|
# This function is overridden to give a better doc comment.
|
|
# This function is overridden to give a better doc comment.
|
|
super(EnumDescriptor, self).CopyToProto(proto)
|
|
super(EnumDescriptor, self).CopyToProto(proto)
|
|
@@ -674,14 +667,15 @@ class EnumValueDescriptor(DescriptorBase):
|
|
|
|
|
|
"""Descriptor for a single value within an enum.
|
|
"""Descriptor for a single value within an enum.
|
|
|
|
|
|
- name: (str) Name of this value.
|
|
|
|
- index: (int) Dense, 0-indexed index giving the order that this
|
|
|
|
|
|
+ Attributes:
|
|
|
|
+ name (str): Name of this value.
|
|
|
|
+ index (int): Dense, 0-indexed index giving the order that this
|
|
value appears textually within its enum in the .proto file.
|
|
value appears textually within its enum in the .proto file.
|
|
- number: (int) Actual number assigned to this enum value.
|
|
|
|
- type: (EnumDescriptor) EnumDescriptor to which this value
|
|
|
|
- belongs. Set by EnumDescriptor's constructor if we're
|
|
|
|
|
|
+ number (int): Actual number assigned to this enum value.
|
|
|
|
+ type (EnumDescriptor): :class:`EnumDescriptor` to which this value
|
|
|
|
+ belongs. Set by :class:`EnumDescriptor`'s constructor if we're
|
|
passed into one.
|
|
passed into one.
|
|
- options: (descriptor_pb2.EnumValueOptions) Enum value options message or
|
|
|
|
|
|
+ options (descriptor_pb2.EnumValueOptions): Enum value options message or
|
|
None to use default enum value options options.
|
|
None to use default enum value options options.
|
|
"""
|
|
"""
|
|
|
|
|
|
@@ -713,14 +707,15 @@ class EnumValueDescriptor(DescriptorBase):
|
|
class OneofDescriptor(DescriptorBase):
|
|
class OneofDescriptor(DescriptorBase):
|
|
"""Descriptor for a oneof field.
|
|
"""Descriptor for a oneof field.
|
|
|
|
|
|
- name: (str) Name of the oneof field.
|
|
|
|
- full_name: (str) Full name of the oneof field, including package name.
|
|
|
|
- index: (int) 0-based index giving the order of the oneof field inside
|
|
|
|
|
|
+ Attributes:
|
|
|
|
+ name (str): Name of the oneof field.
|
|
|
|
+ full_name (str): Full name of the oneof field, including package name.
|
|
|
|
+ index (int): 0-based index giving the order of the oneof field inside
|
|
its containing type.
|
|
its containing type.
|
|
- containing_type: (Descriptor) Descriptor of the protocol message
|
|
|
|
- type that contains this field. Set by the Descriptor constructor
|
|
|
|
|
|
+ containing_type (Descriptor): :class:`Descriptor` of the protocol message
|
|
|
|
+ type that contains this field. Set by the :class:`Descriptor` constructor
|
|
if we're passed into one.
|
|
if we're passed into one.
|
|
- fields: (list of FieldDescriptor) The list of field descriptors this
|
|
|
|
|
|
+ fields (list[FieldDescriptor]): The list of field descriptors this
|
|
oneof can contain.
|
|
oneof can contain.
|
|
"""
|
|
"""
|
|
|
|
|
|
@@ -750,18 +745,19 @@ class ServiceDescriptor(_NestedDescriptorBase):
|
|
|
|
|
|
"""Descriptor for a service.
|
|
"""Descriptor for a service.
|
|
|
|
|
|
- name: (str) Name of the service.
|
|
|
|
- full_name: (str) Full name of the service, including package name.
|
|
|
|
- index: (int) 0-indexed index giving the order that this services
|
|
|
|
|
|
+ Attributes:
|
|
|
|
+ name (str): Name of the service.
|
|
|
|
+ full_name (str): Full name of the service, including package name.
|
|
|
|
+ index (int): 0-indexed index giving the order that this services
|
|
definition appears within the .proto file.
|
|
definition appears within the .proto file.
|
|
- methods: (list of MethodDescriptor) List of methods provided by this
|
|
|
|
|
|
+ methods (list[MethodDescriptor]): List of methods provided by this
|
|
service.
|
|
service.
|
|
- methods_by_name: (dict str -> MethodDescriptor) Same MethodDescriptor
|
|
|
|
- objects as in |methods_by_name|, but indexed by "name" attribute in each
|
|
|
|
- MethodDescriptor.
|
|
|
|
- options: (descriptor_pb2.ServiceOptions) Service options message or
|
|
|
|
|
|
+ methods_by_name (dict(str, MethodDescriptor)): Same
|
|
|
|
+ :class:`MethodDescriptor` objects as in :attr:`methods_by_name`, but
|
|
|
|
+ indexed by "name" attribute in each :class:`MethodDescriptor`.
|
|
|
|
+ options (descriptor_pb2.ServiceOptions): Service options message or
|
|
None to use default service options.
|
|
None to use default service options.
|
|
- file: (FileDescriptor) Reference to file info.
|
|
|
|
|
|
+ file (FileDescriptor): Reference to file info.
|
|
"""
|
|
"""
|
|
|
|
|
|
if _USE_C_DESCRIPTORS:
|
|
if _USE_C_DESCRIPTORS:
|
|
@@ -788,14 +784,21 @@ class ServiceDescriptor(_NestedDescriptorBase):
|
|
method.containing_service = self
|
|
method.containing_service = self
|
|
|
|
|
|
def FindMethodByName(self, name):
|
|
def FindMethodByName(self, name):
|
|
- """Searches for the specified method, and returns its descriptor."""
|
|
|
|
|
|
+ """Searches for the specified method, and returns its descriptor.
|
|
|
|
+
|
|
|
|
+ Args:
|
|
|
|
+ name (str): Name of the method.
|
|
|
|
+ Returns:
|
|
|
|
+ MethodDescriptor or None: the desctiptor for the requested method, if
|
|
|
|
+ found.
|
|
|
|
+ """
|
|
return self.methods_by_name.get(name, None)
|
|
return self.methods_by_name.get(name, None)
|
|
|
|
|
|
def CopyToProto(self, proto):
|
|
def CopyToProto(self, proto):
|
|
"""Copies this to a descriptor_pb2.ServiceDescriptorProto.
|
|
"""Copies this to a descriptor_pb2.ServiceDescriptorProto.
|
|
|
|
|
|
Args:
|
|
Args:
|
|
- proto: An empty descriptor_pb2.ServiceDescriptorProto.
|
|
|
|
|
|
+ proto (descriptor_pb2.ServiceDescriptorProto): An empty descriptor proto.
|
|
"""
|
|
"""
|
|
# This function is overridden to give a better doc comment.
|
|
# This function is overridden to give a better doc comment.
|
|
super(ServiceDescriptor, self).CopyToProto(proto)
|
|
super(ServiceDescriptor, self).CopyToProto(proto)
|
|
@@ -805,15 +808,18 @@ class MethodDescriptor(DescriptorBase):
|
|
|
|
|
|
"""Descriptor for a method in a service.
|
|
"""Descriptor for a method in a service.
|
|
|
|
|
|
- name: (str) Name of the method within the service.
|
|
|
|
- full_name: (str) Full name of method.
|
|
|
|
- index: (int) 0-indexed index of the method inside the service.
|
|
|
|
- containing_service: (ServiceDescriptor) The service that contains this
|
|
|
|
- method.
|
|
|
|
- input_type: The descriptor of the message that this method accepts.
|
|
|
|
- output_type: The descriptor of the message that this method returns.
|
|
|
|
- options: (descriptor_pb2.MethodOptions) Method options message or
|
|
|
|
- None to use default method options.
|
|
|
|
|
|
+ Attributes:
|
|
|
|
+ name (str): Name of the method within the service.
|
|
|
|
+ full_name (str): Full name of method.
|
|
|
|
+ index (int): 0-indexed index of the method inside the service.
|
|
|
|
+ containing_service (ServiceDescriptor): The service that contains this
|
|
|
|
+ method.
|
|
|
|
+ input_type (Descriptor): The descriptor of the message that this method
|
|
|
|
+ accepts.
|
|
|
|
+ output_type (Descriptor): The descriptor of the message that this method
|
|
|
|
+ returns.
|
|
|
|
+ options (descriptor_pb2.MethodOptions or None): Method options message, or
|
|
|
|
+ None to use default method options.
|
|
"""
|
|
"""
|
|
|
|
|
|
if _USE_C_DESCRIPTORS:
|
|
if _USE_C_DESCRIPTORS:
|
|
@@ -844,24 +850,32 @@ class MethodDescriptor(DescriptorBase):
|
|
class FileDescriptor(DescriptorBase):
|
|
class FileDescriptor(DescriptorBase):
|
|
"""Descriptor for a file. Mimics the descriptor_pb2.FileDescriptorProto.
|
|
"""Descriptor for a file. Mimics the descriptor_pb2.FileDescriptorProto.
|
|
|
|
|
|
- Note that enum_types_by_name, extensions_by_name, and dependencies
|
|
|
|
- fields are only set by the message_factory module, and not by the
|
|
|
|
- generated proto code.
|
|
|
|
-
|
|
|
|
- name: name of file, relative to root of source tree.
|
|
|
|
- package: name of the package
|
|
|
|
- syntax: string indicating syntax of the file (can be "proto2" or "proto3")
|
|
|
|
- serialized_pb: (str) Byte string of serialized
|
|
|
|
- descriptor_pb2.FileDescriptorProto.
|
|
|
|
- dependencies: List of other FileDescriptors this FileDescriptor depends on.
|
|
|
|
- public_dependencies: A list of FileDescriptors, subset of the dependencies
|
|
|
|
- above, which were declared as "public".
|
|
|
|
- message_types_by_name: Dict of message names and their descriptors.
|
|
|
|
- enum_types_by_name: Dict of enum names and their descriptors.
|
|
|
|
- extensions_by_name: Dict of extension names and their descriptors.
|
|
|
|
- services_by_name: Dict of services names and their descriptors.
|
|
|
|
- pool: the DescriptorPool this descriptor belongs to. When not passed to the
|
|
|
|
- constructor, the global default pool is used.
|
|
|
|
|
|
+ Note that :attr:`enum_types_by_name`, :attr:`extensions_by_name`, and
|
|
|
|
+ :attr:`dependencies` fields are only set by the
|
|
|
|
+ :py:mod:`google.protobuf.message_factory` module, and not by the generated
|
|
|
|
+ proto code.
|
|
|
|
+
|
|
|
|
+ Attributes:
|
|
|
|
+ name (str): Name of file, relative to root of source tree.
|
|
|
|
+ package (str): Name of the package
|
|
|
|
+ syntax (str): string indicating syntax of the file (can be "proto2" or
|
|
|
|
+ "proto3")
|
|
|
|
+ serialized_pb (bytes): Byte string of serialized
|
|
|
|
+ :class:`descriptor_pb2.FileDescriptorProto`.
|
|
|
|
+ dependencies (list[FileDescriptor]): List of other :class:`FileDescriptor`
|
|
|
|
+ objects this :class:`FileDescriptor` depends on.
|
|
|
|
+ public_dependencies (list[FileDescriptor]): A subset of
|
|
|
|
+ :attr:`dependencies`, which were declared as "public".
|
|
|
|
+ message_types_by_name (dict(str, Descriptor)): Mapping from message names
|
|
|
|
+ to their :class:`Desctiptor`.
|
|
|
|
+ enum_types_by_name (dict(str, EnumDescriptor)): Mapping from enum names to
|
|
|
|
+ their :class:`EnumDescriptor`.
|
|
|
|
+ extensions_by_name (dict(str, FieldDescriptor)): Mapping from extension
|
|
|
|
+ names declared at file scope to their :class:`FieldDescriptor`.
|
|
|
|
+ services_by_name (dict(str, ServiceDescriptor)): Mapping from services'
|
|
|
|
+ names to their :class:`ServiceDescriptor`.
|
|
|
|
+ pool (DescriptorPool): The pool this descriptor belongs to. When not
|
|
|
|
+ passed to the constructor, the global default pool is used.
|
|
"""
|
|
"""
|
|
|
|
|
|
if _USE_C_DESCRIPTORS:
|
|
if _USE_C_DESCRIPTORS:
|