A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://proto-plus-python.readthedocs.io/en/stable/reference/message.html below:

Message and Field — Proto Plus for Python documentation

Proto Plus for Python Message and Field
class proto.message.Message(mapping=None, *, ignore_unknown_fields=False, **kwargs)[source]

The abstract base class for a message.

Parameters:
classmethod pb(obj=None, *, coerce: bool = False)

Return the underlying protobuf Message class or instance.

Parameters:
  • obj – If provided, and an instance of cls, return the underlying protobuf instance.
  • coerce (bool) – If provided, will attempt to coerce obj to cls if it is not already an instance.
classmethod wrap(pb)

Return a Message object that shallowly wraps the descriptor.

Parameters: pb – A protocol buffer object, such as would be returned by pb().
classmethod serialize(instance) → bytes

Return the serialized proto.

Parameters: instance – An instance of this message type, or something compatible (accepted by the type’s constructor). Returns: The serialized representation of the protocol buffer. Return type: bytes
classmethod deserialize(payload: bytes) → proto.message.Message

Given a serialized proto, deserialize it into a Message instance.

Parameters: payload (bytes) – The serialized proto. Returns: An instance of the message class against which this method was called. Return type: Message
classmethod to_json(instance, *, use_integers_for_enums=True, including_default_value_fields=True, preserving_proto_field_name=False, indent=2) → str

Given a message instance, serialize it to json

Parameters:
  • instance – An instance of this message type, or something compatible (accepted by the type’s constructor).
  • use_integers_for_enums (Optional(bool)) – An option that determines whether enum values should be represented by strings (False) or integers (True). Default is True.
  • preserving_proto_field_name (Optional(bool)) – An option that determines whether field name representations preserve proto case (snake_case) or use lowerCamelCase. Default is False.
  • indent – The JSON object will be pretty-printed with this indent level. An indent level of 0 or negative will only insert newlines. Pass None for the most compact representation without newlines.
Returns:

The json string representation of the protocol buffer.

Return type:

str

classmethod from_json(payload, *, ignore_unknown_fields=False) → proto.message.Message

Given a json string representing an instance, parse it into a message.

Parameters:
  • paylod – A json string representing a message.
  • ignore_unknown_fields (Optional(bool)) – If True, do not raise errors for unknown fields.
Returns:

An instance of the message class against which this method was called.

Return type:

Message

classmethod to_dict(instance, *, use_integers_for_enums=True, preserving_proto_field_name=True, including_default_value_fields=True) → proto.message.Message

Given a message instance, return its representation as a python dict.

Parameters:
  • instance – An instance of this message type, or something compatible (accepted by the type’s constructor).
  • use_integers_for_enums (Optional(bool)) – An option that determines whether enum values should be represented by strings (False) or integers (True). Default is True.
  • preserving_proto_field_name (Optional(bool)) – An option that determines whether field name representations preserve proto case (snake_case) or use lowerCamelCase. Default is True.
  • including_default_value_fields (Optional(bool)) – An option that determines whether the default field values should be included in the results. Default is True.
Returns:
A representation of the protocol buffer using pythonic data structures.

Messages and map fields are represented as dicts, repeated fields are represented as lists.

Return type:

dict

classmethod copy_from(instance, other)

Equivalent for protobuf.Message.CopyFrom

Parameters:
  • instance – An instance of this message type
  • other – (Union[dict, ~.Message): A dictionary or message to reinitialize the values for this message.
class proto.fields.Field(proto_type, *, number: int, message=None, enum=None, oneof: str = None, json_name: str = None, optional: bool = False)[source]

A representation of a type of field in protocol buffers.

descriptor

Return the descriptor for the field.

name

Return the name of the field.

package

Return the package of the field.

pb_type

Return the composite type of the field, or the primitive type if a primitive.

class proto.fields.MapField(key_type, value_type, *, number: int, message=None, enum=None)[source]

A representation of a map field in protocol buffers.

class proto.fields.RepeatedField(proto_type, *, number: int, message=None, enum=None, oneof: str = None, json_name: str = None, optional: bool = False)[source]

A representation of a repeated field in protocol buffers.

class proto.enums.Enum[source]

A enum object that also builds a protobuf enum descriptor.

class proto.enums.ProtoEnumMeta[source]

A metaclass for building and registering protobuf enums.


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