U Xzf_Ó7ã@sTdZdZGdd„deƒZGdd„deƒZGdd„deƒZGdd „d eƒZd d „Zd S) z6Contains an abstract base class for protocol messages.z#robinson@google.com (Will Robinson)c@seZdZdZdS)ÚErrorz Base error type for this module.N©Ú__name__Ú __module__Ú __qualname__Ú__doc__©rrúo/private/var/folders/n9/53xbvtmd7sjg1q1l55xmpg58n4mgng/T/pip-unpacked-wheel-3cr5c46n/google/protobuf/message.pyr'src@seZdZdZdS)Ú DecodeErrorz-Exception raised when deserializing messages.Nrrrrrr ,sr c@seZdZdZdS)Ú EncodeErrorz+Exception raised when serializing messages.Nrrrrrr 1sr c@súeZdZdZgZdZd;dd„Zdd„Zdd„Zd d „Z d d „Z d d„Z dd„Z dd„Z dd„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd „Zd!d"„Zd#d$„Zd%d&„Zd'd(„Zd)d*„Zd+d,„Zd-d.„Zd/d0„Zd1d2„Zd3d4„Zd5d6„Zd7d8„Z d9d:„Z!dS)<ÚMessagezÒAbstract base class for protocol messages. Protocol message classes are almost always generated by the protocol compiler. These generated types subclass Message and implement the methods shown below. NcCst|ƒƒ}| |¡|S©N)ÚtypeÚ MergeFrom)ÚselfÚmemoÚclonerrrÚ __deepcopy__Ps  zMessage.__deepcopy__cCst‚dS)z9Recursively compares two messages by value and structure.N©ÚNotImplementedError©rZ other_msgrrrÚ__eq__UszMessage.__eq__cCs ||k Sr rrrrrÚ__ne__YszMessage.__ne__cCs tdƒ‚dS)Nzunhashable object)Ú TypeError©rrrrÚ__hash__]szMessage.__hash__cCst‚dS©z7Outputs a human-readable representation of the message.NrrrrrÚ__str__`szMessage.__str__cCst‚dSrrrrrrÚ __unicode__dszMessage.__unicode__cCst‚dS)aÆMerges the contents of the specified message into current message. This method merges the contents of the specified message into the current message. Singular fields that are set in the specified message overwrite the corresponding fields in the current message. Repeated fields are appended. Singular sub-messages and groups are recursively merged. Args: other_msg (Message): A message to merge into the current message. Nrrrrrrhs zMessage.MergeFromcCs"||kr dS| ¡| |¡dS)zþCopies the content of the specified message into the current message. The method clears the current message and then merges the specified message using MergeFrom. Args: other_msg (Message): A message to copy into the current one. N)ÚClearrrrrrÚCopyFromus zMessage.CopyFromcCst‚dS)z,Clears all data that was set in the message.Nrrrrrrƒsz Message.ClearcCst‚dS)a Mark this as present in the parent. This normally happens automatically when you assign a field of a sub-message, but sometimes you want to make the sub-message present while keeping it empty. If you find yourself using this, you may want to reconsider your design. NrrrrrÚ SetInParent‡szMessage.SetInParentcCst‚dS)z«Checks if the message is initialized. Returns: bool: The method returns True if the message is initialized (i.e. all of its required fields are set). NrrrrrÚ IsInitialized‘szMessage.IsInitializedcCst‚dS)aEMerges serialized protocol buffer data into this message. When we find a field in `serialized` that is already present in this message: - If it's a "repeated" field, we append to the end of our list. - Else, if it's a scalar, we overwrite our field. - Else, (it's a nonrepeated composite), we recursively merge into the existing composite. Args: serialized (bytes): Any object that allows us to call ``memoryview(serialized)`` to access a string of bytes using the buffer interface. Returns: int: The number of bytes read from `serialized`. For non-group messages, this will always be `len(serialized)`, but for messages which are actually groups, this will generally be less than `len(serialized)`, since we must stop when we reach an ``END_GROUP`` tag. Note that if we *do* stop because of an ``END_GROUP`` tag, the number of bytes returned does not include the bytes for the ``END_GROUP`` tag information. Raises: DecodeError: if the input cannot be parsed. Nr©rÚ serializedrrrÚMergeFromString szMessage.MergeFromStringcCs| ¡| |¡S)z„Parse serialized protocol buffer data into this message. Like :func:`MergeFromString()`, except we clear the object first. )rr$r"rrrÚParseFromStringÁszMessage.ParseFromStringcKst‚dS)aÓSerializes the protocol message to a binary string. Keyword Args: deterministic (bool): If true, requests deterministic serialization of the protobuf, with predictable ordering of map keys. Returns: A binary string representation of the message if all of the required fields in the message are set (i.e. the message is initialized). Raises: EncodeError: if the message isn't initialized (see :func:`IsInitialized`). Nr©rÚkwargsrrrÚSerializeToStringÉszMessage.SerializeToStringcKst‚dS)aŠSerializes the protocol message to a binary string. This method is similar to SerializeToString but doesn't check if the message is initialized. Keyword Args: deterministic (bool): If true, requests deterministic serialization of the protobuf, with predictable ordering of map keys. Returns: bytes: A serialized representation of the partial message. Nrr&rrrÚSerializePartialToStringÙs z Message.SerializePartialToStringcCst‚dS)a'Returns a list of (FieldDescriptor, value) tuples for present fields. A message field is non-empty if HasField() would return true. A singular primitive field is non-empty if HasField() would return true in proto2 or it is non zero in proto3. A repeated field is non-empty if it contains at least one element. The fields are ordered by field number. Returns: list[tuple(FieldDescriptor, value)]: field descriptors and values for all fields in the message which are not empty. The values vary by field type. NrrrrrÚ ListFieldsøs zMessage.ListFieldscCst‚dS)aÑChecks if a certain field is set for the message. For a oneof group, checks if any field inside is set. Note that if the field_name is not defined in the message descriptor, :exc:`ValueError` will be raised. Args: field_name (str): The name of the field to check for presence. Returns: bool: Whether a value has been set for the named field. Raises: ValueError: if the `field_name` is not a member of this message. Nr©rÚ field_namerrrÚHasFieldszMessage.HasFieldcCst‚dS)a^Clears the contents of a given field. Inside a oneof group, clears the field set. If the name neither refers to a defined field or oneof group, :exc:`ValueError` is raised. Args: field_name (str): The name of the field to check for presence. Raises: ValueError: if the `field_name` is not a member of this message. Nrr+rrrÚ ClearFields zMessage.ClearFieldcCst‚dS)aEReturns the name of the field that is set inside a oneof group. If no field is set, returns None. Args: oneof_group (str): the name of the oneof group to check. Returns: str or None: The name of the group that is set, or None. Raises: ValueError: no group with the given name exists Nr)rZ oneof_grouprrrÚ WhichOneof'szMessage.WhichOneofcCst‚dS)aìChecks if a certain extension is present for this message. Extensions are retrieved using the :attr:`Extensions` mapping (if present). Args: extension_handle: The handle for the extension to check. Returns: bool: Whether the extension is present for this message. Raises: KeyError: if the extension is repeated. Similar to repeated fields, there is no separate notion of presence: a "not present" repeated extension is an empty list. Nr©rZextension_handlerrrÚ HasExtension7szMessage.HasExtensioncCst‚dS)zxClears the contents of a given extension. Args: extension_handle: The handle for the extension to clear. Nrr0rrrÚClearExtensionIszMessage.ClearExtensioncCst‚dS)zqReturns the UnknownFieldSet. Returns: UnknownFieldSet: The unknown fields stored in this message. NrrrrrÚ UnknownFieldsQszMessage.UnknownFieldscCst‚dS)zlClears all fields in the :class:`UnknownFieldSet`. This operation is recursive for nested message. NrrrrrÚDiscardUnknownFieldsYszMessage.DiscardUnknownFieldscCst‚dS)z¿Returns the serialized size of this message. Recursively calls ByteSize() on all contained messages. Returns: int: The number of bytes required to serialize this message. NrrrrrÚByteSize`szMessage.ByteSizecCst‚dS)a6Internal method used by the protocol message implementation. Clients should not call this directly. Sets a listener that this message will call on certain state transitions. The purpose of this method is to register back-edges from children to parents at runtime, for the purpose of setting "has" bits and byte-size-dirty bits in the parent and ancestor objects whenever a child or descendant object is modified. If the client wants to disconnect this Message from the object tree, she explicitly sets callback to None. If message_listener is None, unregisters any existing listener. Otherwise, message_listener must implement the MessageListener interface in internal/message_listener.py, and we discard any listener registered via a previous _SetListener() call. Nr)rZmessage_listenerrrrÚ _SetListenerjszMessage._SetListenercCst| ¡d�S)úSupport the pickle protocol.)r#)Údictr)rrrrÚ __getstate__szMessage.__getstate__cCs2| ¡|d}t|tƒs$| d¡}| |¡dS)r7r#Úlatin1N)Ú__init__Ú isinstanceÚbytesÚencoder%)rÚstater#rrrÚ __setstate__ƒs   zMessage.__setstate__cCs8|j}|jdkr"t|ƒd| ¡fS|}t|jf| ¡fS)Nr)Ú DESCRIPTORZcontaining_typer r9Ú_InternalConstructMessageÚ full_name)rZmessage_descriptorÚ containerrrrÚ __reduce__�s ÿzMessage.__reduce__)N)"rrrrÚ __slots__rArrrrrrrrrr r!r$r%r(r)r*r-r.r/r1r2r3r4r5r6r9r@rErrrrr 6s>   !  r cCsddlm}| ¡ |¡ƒS)zConstructs a nested message.é)Úsymbol_database)Zgoogle.protobufrHZDefaultZ GetSymbol)rCrHrrrrB™s rBN) rÚ __author__Ú Exceptionrr r Úobjectr rBrrrrÚ#se