Descriptors essentially contain exactly the information found in a .proto file, in types that make this information accessible in Python.
google.protobuf.descriptor.
Descriptor
(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, create_key=None)¶
Descriptor for a protocol message type.
name
¶
Name of this protocol message type.
full_name
¶
Fully-qualified name of this protocol message type, which will include protocol “package” name and the name of any enclosing types.
containing_type
¶
Reference to the descriptor of the type containing us, or None if this is top-level.
fields
¶
Field descriptors for all fields in this type.
fields_by_number
¶
Same FieldDescriptor
objects as in fields
, but indexed by “number” attribute in each FieldDescriptor.
fields_by_name
¶
Same FieldDescriptor
objects as in fields
, but indexed by “name” attribute in each FieldDescriptor
.
nested_types
¶
Descriptor references for all protocol message types nested within this one.
nested_types_by_name
¶
Same Descriptor objects as in nested_types
, but indexed by “name” attribute in each Descriptor.
enum_types
¶
EnumDescriptor
references for all enums contained within this type.
enum_types_by_name
¶
Same EnumDescriptor
objects as in enum_types
, but indexed by “name” attribute in each EnumDescriptor.
enum_values_by_name
¶
Dict mapping from enum value name to EnumValueDescriptor
for that value.
extensions
¶
All extensions defined directly within this message type (NOT within a nested type).
extensions_by_name
¶
Same FieldDescriptor objects as extensions
, but indexed by “name” attribute of each FieldDescriptor.
is_extendable
¶
Does this type define any extension ranges?
oneofs
¶
The list of descriptors for oneof fields in this message.
oneofs_by_name
¶
Same objects as in oneofs
, but indexed by “name” attribute.
file
¶
Reference to file descriptor.
CopyToProto
(proto)¶
Copies this to a descriptor_pb2.DescriptorProto.
proto – An empty descriptor_pb2.DescriptorProto.
EnumValueName
(enum, value)¶
Returns the string name of an enum value.
This is just a small helper method to simplify a common operation.
enum – string name of the Enum.
value – int, value of the enum.
string name of the enum value.
KeyError if either the Enum doesn't exist or the value is not a valid – value for the enum.
GetOptions
()¶
Retrieves descriptor options.
This method returns the options set or creates the default options for the descriptor.
fields_by_camelcase_name
¶
Same FieldDescriptor objects as in fields
, but indexed by FieldDescriptor.camelcase_name
.
google.protobuf.descriptor.
DescriptorBase
(options, serialized_options, options_class_name)¶
Descriptors base class.
This class is the base of all descriptor classes. It provides common options related functionality.
has_options
¶
True if the descriptor has non-default options. Usually it is not necessary to read this – just call GetOptions() which will happily return the default instance. However, it’s sometimes useful for efficiency, and also useful inside the protobuf implementation to avoid some bootstrapping issues.
GetOptions
()¶
Retrieves descriptor options.
This method returns the options set or creates the default options for the descriptor.
google.protobuf.descriptor.
EnumDescriptor
(name, full_name, filename, values, containing_type=None, options=None, serialized_options=None, file=None, serialized_start=None, serialized_end=None, create_key=None)¶
Descriptor for an enum defined in a .proto file.
name
¶
Name of the enum type.
full_name
¶
Full name of the type, including package name and any enclosing type(s).
values
¶
List of the values in this enum.
values_by_name
¶
Same as values
, but indexed by the “name” field of each EnumValueDescriptor.
values_by_number
¶
Same as values
, but indexed by the “number” field of each EnumValueDescriptor.
containing_type
¶
Descriptor of the immediate containing 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 if we’re passed into one.
file
¶
Reference to file descriptor.
options
¶
Enum options message or None to use default enum options.
CopyToProto
(proto)¶
Copies this to a descriptor_pb2.EnumDescriptorProto.
proto (descriptor_pb2.EnumDescriptorProto) – An empty descriptor proto.
GetOptions
()¶
Retrieves descriptor options.
This method returns the options set or creates the default options for the descriptor.
google.protobuf.descriptor.
EnumValueDescriptor
(name, index, number, type=None, options=None, serialized_options=None, create_key=None)¶
Descriptor for a single value within an enum.
name
¶
Name of this value.
index
¶
Dense, 0-indexed index giving the order that this value appears textually within its enum in the .proto file.
number
¶
Actual number assigned to this enum value.
type
¶
EnumDescriptor
to which this value belongs. Set by EnumDescriptor
’s constructor if we’re passed into one.
options
¶
Enum value options message or None to use default enum value options options.
GetOptions
()¶
Retrieves descriptor options.
This method returns the options set or creates the default options for the descriptor.
google.protobuf.descriptor.
Error
¶
Base error for this module.
args
¶
with_traceback
()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
google.protobuf.descriptor.
FieldDescriptor
(name, full_name, index, number, type, cpp_type, label, default_value, message_type, enum_type, containing_type, is_extension, extension_scope, options=None, serialized_options=None, has_default_value=True, containing_oneof=None, json_name=None, file=None, create_key=None)¶
Descriptor for a single field in a .proto file.
name
¶
Name of this field, exactly as it appears in .proto.
full_name
¶
Name of this field, including containing scope. This is particularly relevant for extensions.
index
¶
Dense, 0-indexed index giving the order that this field textually appears within its message in the .proto file.
number
¶
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 represent this field.
label
¶
(One of the LABEL_* constants below) Tells whether this field is optional, required, or repeated.
has_default_value
¶
True if this field has a default value defined, otherwise false.
default_value
¶
Default value of this field. Only meaningful for non-repeated scalar fields. Repeated fields should always set this to [], and non-repeated composite fields should always set this to None.
Varies
containing_type
¶
Descriptor of the protocol message type that contains this field. Set by the Descriptor constructor if we’re passed into one. Somewhat confusingly, for extension fields, this is the descriptor of the EXTENDED message, not the descriptor of the message containing this field. (See is_extension and extension_scope below).
message_type
¶
If a composite field, a descriptor of the message type contained in this field. Otherwise, this is None.
enum_type
¶
If this field contains an enum, a descriptor of that enum. Otherwise, this is None.
is_extension
¶
True iff this describes an extension field.
extension_scope
¶
Only meaningful if is_extension is True. Gives the message that immediately contains this extension field. Will be None iff we’re a top-level (file-level) extension field.
options
¶
Protocol message field options or None to use default field options.
containing_oneof
¶
If the field is a member of a oneof union, contains its descriptor. Otherwise, None.
file
¶
Reference to file descriptor.
CPPTYPE_BOOL
= 7¶
CPPTYPE_DOUBLE
= 5¶
CPPTYPE_ENUM
= 8¶
CPPTYPE_FLOAT
= 6¶
CPPTYPE_INT32
= 1¶
CPPTYPE_INT64
= 2¶
CPPTYPE_MESSAGE
= 10¶
CPPTYPE_STRING
= 9¶
CPPTYPE_UINT32
= 3¶
CPPTYPE_UINT64
= 4¶
FIRST_RESERVED_FIELD_NUMBER
= 19000¶
GetOptions
()¶
Retrieves descriptor options.
This method returns the options set or creates the default options for the descriptor.
LABEL_OPTIONAL
= 1¶
LABEL_REPEATED
= 3¶
LABEL_REQUIRED
= 2¶
LAST_RESERVED_FIELD_NUMBER
= 19999¶
MAX_CPPTYPE
= 10¶
MAX_FIELD_NUMBER
= 536870911¶
MAX_LABEL
= 3¶
MAX_TYPE
= 18¶
ProtoTypeToCppProtoType
(proto_type)¶
Converts from a Python proto type to a C++ Proto Type.
The Python ProtocolBuffer classes specify both the ‘Python’ datatype and the ‘C++’ datatype - and they’re not the same. This helper method should translate from one to another.
proto_type – the Python proto type (descriptor.FieldDescriptor.TYPE_*)
descriptor.FieldDescriptor.CPPTYPE_*, the C++ type.
TypeTransformationError – when the Python proto type isn’t known.
TYPE_BOOL
= 8¶
TYPE_BYTES
= 12¶
TYPE_DOUBLE
= 1¶
TYPE_ENUM
= 14¶
TYPE_FIXED32
= 7¶
TYPE_FIXED64
= 6¶
TYPE_FLOAT
= 2¶
TYPE_GROUP
= 10¶
TYPE_INT32
= 5¶
TYPE_INT64
= 3¶
TYPE_MESSAGE
= 11¶
TYPE_SFIXED32
= 15¶
TYPE_SFIXED64
= 16¶
TYPE_SINT32
= 17¶
TYPE_SINT64
= 18¶
TYPE_STRING
= 9¶
TYPE_UINT32
= 13¶
TYPE_UINT64
= 4¶
camelcase_name
¶
Camelcase name of this field.
the name in CamelCase.
has_presence
¶
Whether the field distinguishes between unpopulated and default values.
RuntimeError – singular field that is not linked with message nor file.
google.protobuf.descriptor.
FileDescriptor
(name, package, options=None, serialized_options=None, serialized_pb=None, dependencies=None, public_dependencies=None, syntax=None, pool=None, create_key=None)¶
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 google.protobuf.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
¶
Byte string of serialized descriptor_pb2.FileDescriptorProto
.
dependencies
¶
List of other FileDescriptor
objects this FileDescriptor
depends on.
public_dependencies
¶
A subset of dependencies
, which were declared as “public”.
message_types_by_name
¶
Mapping from message names to their Descriptor
.
enum_types_by_name
¶
Mapping from enum names to their EnumDescriptor
.
extensions_by_name
¶
Mapping from extension names declared at file scope to their FieldDescriptor
.
services_by_name
¶
Mapping from services’ names to their ServiceDescriptor
.
pool
¶
The pool this descriptor belongs to. When not passed to the constructor, the global default pool is used.
CopyToProto
(proto)¶
Copies this to a descriptor_pb2.FileDescriptorProto.
proto – An empty descriptor_pb2.FileDescriptorProto.
GetOptions
()¶
Retrieves descriptor options.
This method returns the options set or creates the default options for the descriptor.
google.protobuf.descriptor.
MakeDescriptor
(desc_proto, package='', build_file_if_cpp=True, syntax=None)¶
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.
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.
A Descriptor for protobuf messages.
google.protobuf.descriptor.
MethodDescriptor
(name, full_name, index, containing_service, input_type, output_type, client_streaming=False, server_streaming=False, options=None, serialized_options=None, create_key=None)¶
Descriptor for a method in a service.
name
¶
Name of the method within the service.
full_name
¶
Full name of method.
index
¶
0-indexed index of the method inside the service.
containing_service
¶
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.
client_streaming
¶
Whether this method uses client streaming.
server_streaming
¶
Whether this method uses server streaming.
options
¶
Method options message, or None to use default method options.
CopyToProto
(proto)¶
Copies this to a descriptor_pb2.MethodDescriptorProto.
proto (descriptor_pb2.MethodDescriptorProto) – An empty descriptor proto.
Error – If self couldn’t be serialized, due to too few constructor arguments.
GetOptions
()¶
Retrieves descriptor options.
This method returns the options set or creates the default options for the descriptor.
google.protobuf.descriptor.
OneofDescriptor
(name, full_name, index, containing_type, fields, options=None, serialized_options=None, create_key=None)¶
Descriptor for a oneof field.
name
¶
Name of the oneof field.
full_name
¶
Full name of the oneof field, including package name.
index
¶
0-based index giving the order of the oneof field inside its containing type.
containing_type
¶
Descriptor
of the protocol message type that contains this field. Set by the Descriptor
constructor if we’re passed into one.
fields
¶
The list of field descriptors this oneof can contain.
GetOptions
()¶
Retrieves descriptor options.
This method returns the options set or creates the default options for the descriptor.
google.protobuf.descriptor.
ServiceDescriptor
(name, full_name, index, methods, options=None, serialized_options=None, file=None, serialized_start=None, serialized_end=None, create_key=None)¶
Descriptor for a service.
name
¶
Name of the service.
full_name
¶
Full name of the service, including package name.
index
¶
0-indexed index giving the order that this services definition appears within the .proto file.
methods
¶
List of methods provided by this service.
methods_by_name
¶
Same MethodDescriptor
objects as in methods_by_name
, but indexed by “name” attribute in each MethodDescriptor
.
options
¶
Service options message or None to use default service options.
file
¶
Reference to file info.
CopyToProto
(proto)¶
Copies this to a descriptor_pb2.ServiceDescriptorProto.
proto (descriptor_pb2.ServiceDescriptorProto) – An empty descriptor proto.
FindMethodByName
(name)¶
Searches for the specified method, and returns its descriptor.
name (str) – Name of the method.
the descriptor for the requested method, if found.
GetOptions
()¶
Retrieves descriptor options.
This method returns the options set or creates the default options for the descriptor.
google.protobuf.descriptor.
TypeTransformationError
¶
Error transforming between python proto type and corresponding C++ type.
args
¶
with_traceback
()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4