protobuf - Registry for Google Protocol Buffer messages and enums¶
Overview¶
This module provides central registry for Google Protocol Buffer messages and enums.
The generated *_pb2.py
protobuf files could be registered using register_decriptor
or load_registered
function. The registry could be then used to obtain information
about protobuf messages or enum types, or to create message instances or enum values.
Functions¶
register_decriptor¶
load_registered¶
-
firebird.base.protobuf.
load_registered
(group)¶ Load registered protobuf packages.
Protobuf packages must register the pb2-file DESCRIPTOR in
entry_points
section ofsetup.cfg
file.- Parameters
group (
str
) – Entry-point group name.
Example
# setup.cfg: [options.entry_points] firebird.base.protobuf = firebird.base.lib_a = firebird.base.lib_a_pb2:DESCRIPTOR firebird.base.lib_b = firebird.base.lib_b_pb2:DESCRIPTOR firebird.base.lib_c = firebird.base.lib_c_pb2:DESCRIPTOR # will be loaded with: load_registered('firebird.base.protobuf')
- Return type
is_msg_registered¶
is_enum_registered¶
get_enum_type¶
get_enum_value_name¶
create_message¶
-
firebird.base.protobuf.
create_message
(name, serialized=None)¶ Returns new protobuf message instance.
get_enum_field_type¶
struct2dict¶
Data classes¶
ProtoMessageType¶
ProtoEnumType¶
-
class
firebird.base.protobuf.
ProtoEnumType
(descriptor)¶ Bases:
firebird.base.types.Distinct
Google protobuf enum type
-
__getattr__
(name)¶ Returns the value corresponding to the given enum name.
-
get_value_name
(number)¶ Returns a string containing the name of an enum value.
-
items
()¶ Return a list of the (name, value) pairs of the enum.
These are returned in the order they were defined in the .proto file.
-
keys
()¶ Return a list of the string names in the enum.
These are returned in the order they were defined in the .proto file.
-
values
()¶ Return a list of the integer values in the enum.
These are returned in the order they were defined in the .proto file.
-
descriptor
: google.protobuf.descriptor.EnumDescriptor¶
-