HEX
Server: LiteSpeed
System: Linux srv146.niagahoster.com 4.18.0-553.30.1.lve.el8.x86_64 #1 SMP Tue Dec 3 01:21:19 UTC 2024 x86_64
User: kodi1989 (1633)
PHP: 8.1.34
Disabled: symlink,shell_exec,exec,popen,system,dl,passthru,escapeshellarg,escapeshellcmd,show_source,pcntl_exec
Upload Files
File: //opt/alt/python37/lib/python3.7/site-packages/proto/__pycache__/message.cpython-37.pyc
B

��f��@sddlZddlZddlZddlZddlmZmZmZddlZddl	Z
ddl	mZddl	mZddl
mZmZmZddlmZddlmZddlmZdd	lmZdd
lmZddlmZddlmZdd
lmZe
jjZ e�Z!Gdd�de"�Z#Gdd�de#d�Z$Gdd�d�Z%dZ&dS)�N)�List�Optional�Type)�descriptor_pb2)�message)�
MessageToDict�
MessageToJson�Parse)�
_file_info)�
_package_info)�Field)�MapField)�
RepeatedField)�Marshal)�	ProtoType)�has_upbcs eZdZdZ�fdd�Zedd��Zedd��Zdd	�Z	d-dd�e
d�d
d�Z�fdd�Ze
d�dd�Ze
dd�dd�Zee
d
d�dd�Zee
ee
d
d�dd�Zee
ee
e
d�dd�Zd d
ddd!d
d
d"�ed�d#d$�Zdd%�dd�d&d'�Zd d d
d
d
d(�dd�d)d*�Zd+d,�Z�ZS).�MessageMetaz<A metaclass for building and registering Message subclasses.c	s�|st��||||�St�||�\}}t|�d|��d���d�krn��d�}�d|d��|dd��d�|f���	d�}i}x�|�
�D]�\}	}
t|
t�s�q�dj
t�ddd�|	��|	d	|	d	��d�d
�}t�|�dd�dj
|�d|�|d
�ddid��}t|
jdd�|d<t|
jd|
j|
jd�|d<t|tf|�||<ttj|
j||d�||	<q�W|�|�g}
i}t��}t �}d	}�x|�
�D�]
\}	}
t|
t��s�|
||	<�q�|	|||d�|
_!|
�"|
�|
j#�r�|�$|
j#t%|��||
j#|
j&_'|
j�rJt|
jt(��sJ|
j}t)|d��r2t*|j+��r2|�+�}|�r�|�,|j-j.j/�nJ|
j�r�t|
jt(��s�t)|
jd��rx|
jj0j+n|
jj-}|�r�|�,|j.j/�|d7}�q�Wi}xF|
D]>}
|
j1�r�d�
|
j/�|
_#t%|�|
j&_'||
j#<|
j/||
j/<�q�W|�rt2d|f|�}t3j4�5|�d|�6���}t3j4�7||�}x*|D]"}||j&j8k�r.|j&j8�"|��q.Wt9j:f|�;di��}t9j<|dd�|
D�dd�|�=�D�|d �}�fd!d�|j>�=�D�}x&|D]}|j?�,��@|j>�;|���q�W�fd"d�|jA�=�D�}x&|D]}|jB�,��@|jA�;|���q�Wt%��dk�r4|j&jC�,��@|�n
||j>�<tD|
||||d#�|d<t��||||�}||j0_Ex|j0jF�G�D]}
||
_E�q|W||jH|<|jI|d$��r�|jJ||d%�|S)&N�__qualname__�.z<locals>�z{pascal_key}Entryz_\wcSs|��dd���S)Nr)�group�upper)�m�r�>/opt/alt/python37/lib/python3.7/site-packages/proto/message.py�<lambda>O�z%MessageMeta.__new__.<locals>.<lambda>r)Z
pascal_key�
__module__z{prefix}.{name})�prefix�nameZ	map_entryT)rr�_pb_options)�number�key�)r!�enumr�value)r!r)r�parent_name�index�package�pb�_metaz_{}Z	AttrsMetar cSsg|]
}|j�qSr)�
descriptor)�.0�irrr�
<listcomp>�sz'MessageMeta.__new__.<locals>.<listcomp>cSsg|]}tj|d��qS))r)rZOneofDescriptorProto)r,r-rrrr.�s)r�fieldZ
oneof_decl�optionscs g|]}�|dd�kr|�qS)N���r)r,�p)�
local_pathrrr.�scs g|]}�|dd�kr|�qS)Nr1r)r,r2)r3rrr.�s)�fields�	full_name�marshalr0r()�	new_class)r7Z
fallback_salt)K�super�__new__r�compile�tuple�get�splitr'�join�lstrip�items�
isinstancer
�format�re�sub�replacer�collections�OrderedDictrZmap_key_typeZ
proto_typer$rr�MessagerrZMESSAGEr!�update�setZ	mcls_data�appendZoneof�
setdefault�lenr+Zoneof_index�str�hasattr�callabler)�add�
DESCRIPTOR�filerr*�optional�typer
Z	_FileInfoZproto_file_name�lowerZmaybe_add_descriptor�
dependencyr�MessageOptions�popZDescriptorProto�keys�nestedZnested_type�	MergeFromZnested_enumZ	enum_typeZmessage_type�_MessageInfo�parentr4�values�messages�readyZgenerate_file_pb)�mclsr�bases�attrsr(r6�ixr5Z
map_fieldsr"r/Zmsg_nameZentry_attrsr4Z	new_attrsZoneofsZ
proto_importsr'Z	field_msgZ
field_enumZ	opt_attrs�filename�	file_infoZproto_import�opts�descZchild_pathsZ
child_path�cls)�	__class__)r3rr9-s�
 











zMessageMeta.__new__cKst��S)N)rFrG)rbrrc�kwargsrrr�__prepare__szMessageMeta.__prepare__cCs|jS)N)r*)rjrrr�meta szMessageMeta.metacCsnyPttt��}|�d�|��j}|�dd�|jD��|�dd�|jD��|Stk
rhtt�SXdS)N)	rnr)�wrap�	serialize�deserialize�to_json�	from_json�to_dict�	copy_fromcss|]}|jVqdS)N)r)r,�trrr�	<genexpr>5sz&MessageMeta.__dir__.<locals>.<genexpr>css|]}|jVqdS)N)r)r,�errrrw6s)	rJ�dirrUrIr)rR�nested_types�
enum_types�AttributeError)�self�namesrirrr�__dir__$s
zMessageMeta.__dir__NF)�coercecCs@|dkr|jjSt||�s:|r(||�}ntd||jf��|jS)aHReturn the underlying protobuf Message class or instance.

        Args:
            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.
        Nz%r is not an instance of %s)rnr)rA�	TypeError�__name__�_pb)rj�objr�rrrr)<s	

zMessageMeta.pbcs |�|�}t||��d|�|S)z�Return a Message object that shallowly wraps the descriptor.

        Args:
            pb: A protocol buffer object, such as would be returned by
                :meth:`pb`.
        r�)r9r8�__setattr__)rjr)�instance)rkrrroTs
zMessageMeta.wrap)�returncCs|j|dd���S)aReturn the serialized proto.

        Args:
            instance: An instance of this message type, or something
                compatible (accepted by the type's constructor).

        Returns:
            bytes: The serialized representation of the protocol buffer.
        T)r�)r)�SerializeToString)rjr�rrrrp`s
zMessageMeta.serializerH)�payloadr�cCs|�|���|��S)aGiven a serialized proto, deserialize it into a Message instance.

        Args:
            payload (bytes): The serialized proto.

        Returns:
            ~.Message: An instance of the message class against which this
            method was called.
        )ror)�
FromString)rjr�rrrrqls
zMessageMeta.deserialize)�including_default_value_fieldsr�cCs$tddkr |dk	r t�dt�dS)z�
        Warn Protobuf 5.x+ users that `including_default_value_fields` is deprecated if it is set.

        Args:
            including_default_value_fields (Optional(bool)): The value of `including_default_value_fields` set by the user.
        r)�3�4Nz�The argument `including_default_value_fields` has been removed from
                Protobuf 5.x. Please use `always_print_fields_with_no_presence` instead.
                )�PROTOBUF_VERSION�warnings�warn�DeprecationWarning)rjr�rrr�:_warn_if_including_default_value_fields_is_used_protobuf_5xs

zFMessageMeta._warn_if_including_default_value_fields_is_used_protobuf_5)�$always_print_fields_with_no_presencer�r�cCs$|dk	r |dk	r ||kr td��dS)a�
        Raise Exception if both `always_print_fields_with_no_presence` and `including_default_value_fields` are set
            and the values differ.

        Args:
            always_print_fields_with_no_presence (Optional(bool)): The value of `always_print_fields_with_no_presence` set by the user.
            including_default_value_fields (Optional(bool)): The value of `including_default_value_fields` set by the user.
        Returns:
            None
        Raises:
            ValueError: if both `always_print_fields_with_no_presence` and `including_default_value_fields` are set and
                the values differ.
        Nz`Arguments `always_print_fields_with_no_presence` and `including_default_value_fields` must match)�
ValueError)rjr�r�rrr�0_raise_if_print_fields_values_are_set_and_differ�s
z<MessageMeta._raise_if_print_fields_values_are_set_and_differcCs.|�|�|�||�|dkr&|dkp,|p,|S)a�
        Return true if fields with no presence should be included in the results.
        By default, fields with no presence will be included in the results
        when both `always_print_fields_with_no_presence` and
        `including_default_value_fields` are not set

        Args:
            always_print_fields_with_no_presence (Optional(bool)): The value of `always_print_fields_with_no_presence` set by the user.
            including_default_value_fields (Optional(bool)): The value of `including_default_value_fields` set by the user.
        Returns:
            None
        Raises:
            ValueError: if both `always_print_fields_with_no_presence` and `including_default_value_fields` are set and
                the values differ.
        N)r�r�)rjr�r�rrr�(_normalize_print_fields_without_presence�sz4MessageMeta._normalize_print_fields_without_presenceTr#)�use_integers_for_enumsr��preserving_proto_field_name�	sort_keys�indent�float_precisionr�c
	CsT|�||�}	tddkr4t|�|�||	||||d�St|�|�||	||||d�SdS)aBGiven a message instance, serialize it to json

        Args:
            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.
            including_default_value_fields (Optional(bool)): Deprecated. Use argument
                `always_print_fields_with_no_presence` instead. An option that
                determines whether the default field values should be included in the results.
                This value must match `always_print_fields_with_no_presence`,
                if both arguments are explictly set.
            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.
            sort_keys (Optional(bool)): If True, then the output will be sorted by field names.
                Default is False.
            indent (Optional(int)): 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.
            float_precision (Optional(int)): If set, use this to specify float field valid digits.
                Default is None.
            always_print_fields_with_no_presence (Optional(bool)): If True, fields without
                presence (implicit presence scalars, repeated fields, and map fields) will
                always be serialized. Any field that supports presence is not affected by
                this option (including singular message fields and oneof fields).
                This value must match `including_default_value_fields`,
                if both arguments are explictly set.
        Returns:
            str: The json string representation of the protocol buffer.
        r)r�r�)r�r�r�r�r�r�)r�r�r�r�r�r�N)r�r�rr))
rjr�r�r�r�r�r�r�r��print_fieldsrrrrr�s&-zMessageMeta.to_json)�ignore_unknown_fieldscCs|�}t||j|d�|S)a�Given a json string representing an instance,
        parse it into a message.

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

        Returns:
            ~.Message: An instance of the message class against which this
            method was called.
        )r�)r	r�)rjr�r�r�rrrrss
zMessageMeta.from_json)r�r�r�r�r�cCsL|�||�}tddkr0t|�|�||||d�St|�|�||||d�SdS)aZGiven a message instance, return its representation as a python dict.

        Args:
            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)): Deprecated. Use argument
                `always_print_fields_with_no_presence` instead. An option that
                determines whether the default field values should be included in the results.
                This value must match `always_print_fields_with_no_presence`,
                if both arguments are explictly set.
            float_precision (Optional(int)): If set, use this to specify float field valid digits.
                Default is None.
            always_print_fields_with_no_presence (Optional(bool)): If True, fields without
                presence (implicit presence scalars, repeated fields, and map fields) will
                always be serialized. Any field that supports presence is not affected by
                this option (including singular message fields and oneof fields). This value
                must match `including_default_value_fields`, if both arguments are explictly set.

        Returns:
            dict: A representation of the protocol buffer using pythonic data structures.
                  Messages and map fields are represented as dicts,
                  repeated fields are represented as lists.
        r)r�r�)r�r�r�r�)r�r�r�r�N)r�r�rr))rjr�r�r�r�r�r�r�rrrrt(s(zMessageMeta.to_dictcCsnt||�rt�|�}nDt||���r&n4t|tjj�rD|jjf|�}ntd�|j	|j
j	���|�|��|�dS)z�Equivalent for protobuf.Message.CopyFrom

        Args:
            instance: An instance of this message type
            other: (Union[dict, ~.Message):
                A dictionary or message to reinitialize the values for this message.
        z'invalid argument type to copy to {}: {}N)rArHr)rF�abc�Mappingr*r�rBr�rkZCopyFrom)rjr��otherrrrrujs
zMessageMeta.copy_from)N)r�rr�__doc__r9�classmethodrm�propertyrnr�boolr)ro�bytesrprqrr�r�r�rNrrrsrtru�
__classcell__rr)rkrr*sDp
%@9rcs�eZdZdZddd��fdd�Zdd�Zd	d
�Zdd�Zd
d�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
�fdd�Zdd�Z�fdd�Z�ZS) rHa�The abstract base class for a message.

    Args:
        mapping (Union[dict, ~.Message]): A dictionary or message to be
            used to determine the values for this message.
        ignore_unknown_fields (Optional(bool)): If True, do not raise errors for
            unknown fields. Only applied if `mapping` is a mapping type or there
            are keyword parameters.
        kwargs (dict): Keys and values corresponding to the fields of the
            message.
    NF)r�c	s�|dkr*|s$t��d|j���dS|}n�t||jj�rlt�|�}|rZ|�|jjf|��t��d|�dSt|t|��r�|j	fd|j
i|��dSt|tjj
�r�t�|�}|�|�ntd|jj|f��i}|jj}x�|��D]�\}}|�|�\}��dk�r|�r
q�td�|jj|���y|��|�}Wn~tk
�r�t|t��r�t�rf�fdd�|D�}	n�fdd�|D�}	x"|	D]}
|�|
�||
�d�<�q~W|��|�}YnX|dk	r�|||<q�Wt��d|jjf|��dS)	Nr��mappingz$Invalid constructor input for %s: %rzUnknown field for {}: {}cs.g|]&}|�jjkr|�d��jjkr|�qS)�_)rRZfields_by_name)r,�item)�pb_typerrr.�sz$Message.__init__.<locals>.<listcomp>cs*g|]"}t�|�st�|�d��r|�qS)r�)rO)r,r�)r�rrr.�s
r�)r8r�r*r)rA�copy�deepcopyr\rU�__init__r�rFr�r�rIr�rkr�r6r@�_get_pb_type_from_keyr�rB�to_proto�dict�_upbrY)r}r�r�rl�paramsr6r"r%�pb_valueZkeys_to_updater�)rk)r�rr��sZ







zMessage.__init__cCs^d}y|jj|j}Wn>tk
rT|�d�|jjkrP|�d�}|jj|j}YnX||fS)aYGiven a key, return the corresponding pb_type.

        Args:
            key(str): The name of the field.

        Returns:
            A tuple containing a key and pb_type. The pb_type will be
            the composite type of the field, or the primitive type if a primitive.
            If no corresponding field exists, return None.
        Nr�)r*r4r��KeyError)r}r"r�rrrr��s
zMessage._get_pb_type_from_keycCsnt|���j}dd�|jj��D�}|�dd�|jD��|�dd�|jD��|�t	t
���|�d�|S)NcSsh|]}|�qSrr)r,�f_namerrr�	<setcomp>sz"Message.__dir__.<locals>.<setcomp>css|]}|jVqdS)N)r)r,rrrrrwsz"Message.__dir__.<locals>.<genexpr>css|]}|jVqdS)N)r)r,rxrrrrws)�__bool__�__contains__�__dict__�__getattr__�__getstate__r�__setstate__�__weakref__)rUr)rRr*r4rZrIrzr{ry�object)r}rir~rrrrszMessage.__dir__cst�fdd��jj��D��S)z4Return True if any field is truthy, False otherwise.c3s |]}|�kot�|�VqdS)N)�getattr)r,�k)r}rrrw4sz#Message.__bool__.<locals>.<genexpr>)�anyr*r4rZ)r}r)r}rr�2szMessage.__bool__cCs6t|j|�}y|j�|�Stk
r0t|�SXdS)aRReturn True if this field was set to something non-zero on the wire.

        In most cases, this method will return True when ``__getattr__``
        would return a truthy value and False when it would return a falsy
        value, so explicitly calling this is not useful.

        The exception case is empty messages explicitly set on the wire,
        which are falsy from ``__getattr__``. This method allows to
        distinguish between an explicitly provided empty message and the
        absence of that message, which is useful in some edge cases.

        The most common edge case is the use of ``google.protobuf.BoolValue``
        to get a boolean that distinguishes between ``False`` and ``None``
        (or the same for a string, int, etc.). This library transparently
        handles that case for you, but this method remains available to
        accommodate cases not automatically covered.

        Args:
            key (str): The name of the field.

        Returns:
            bool: Whether the field's value corresponds to a non-empty
                wire serialization.
        N)r�r�ZHasFieldr�r�)r}r"r�rrrr�6s
zMessage.__contains__cCs|j�|�dS)zmDelete the value on the given field.

        This is generally equivalent to setting a falsy value.
        N)r��
ClearField)r}r"rrr�__delattr__\szMessage.__delattr__cCs6t|t|��r|j|jkSt||jj�r2|j|kStS)z7Return True if the messages are equal, False otherwise.)rArUr�r*r)�NotImplemented)r}r�rrr�__eq__cs

zMessage.__eq__cCsR|�|�\}}|dkr*td�|jj|���t|j|�}|jj}|j	||||kd�S)a�Retrieve the given field's value.

        In protocol buffers, the presence of a field on a message is
        sufficient for it to always be "present".

        For primitives, a value of the correct type will always be returned
        (the "falsy" values in protocol buffers consistently match those
        in Python). For repeated fields, the falsy value is always an empty
        sequence.

        For messages, protocol buffers does distinguish between an empty
        message and absence, but this distinction is subtle and rarely
        relevant. Therefore, this method always returns an empty message
        (following the official implementation). To check for message
        presence, use ``key in self`` (in other words, ``__contains__``).

        .. note::

            Some well-known protocol buffer types
            (e.g. ``google.protobuf.Timestamp``) will be converted to
            their Python equivalents. See the ``marshal`` module for
            more details.
        NzUnknown field for {}: {})Zabsent)
r�r|rBrkr�r�r�r*r6Z	to_python)r}r"r�r�r6rrrr�pszMessage.__getattr__cCs
||kS)z9Return True if the messages are unequal, False otherwise.r)r}r�rrr�__ne__�szMessage.__ne__cCs
t|j�S)N)�reprr�)r}rrr�__repr__�szMessage.__repr__cs�|ddkrt��||�S|jj}|�|�\}}|dkrLtd�|jj|���|�	||�}|j
�|�|dk	r�|j
�|jj
f||i��dS)z�Set the value on the given field.

        For well-known protocol buffer types which are marshalled, either
        the protocol buffer object or the Python equivalent is accepted.
        rr�NzUnknown field for {}: {})r8r�r*r6r�r|rBrkr�r�r�r�r\r))r}r"r%r6r�r�)rkrrr��szMessage.__setattr__cCs
|j��S)zSerialize for pickling.)r�r�)r}rrrr��szMessage.__getstate__cs"|j���|�}t��d|�dS)zDeserialization for pickling.r�N)r*r)r�r8r�)r}r%Znew_pb)rkrrr��szMessage.__setstate__)N)r�rrr�r�r�rr�r�r�r�r�r�r�r�r�r�r�rr)rkrrH�sc&
!rH)�	metaclassc@sFeZdZdZeeeeeej	dd�dd�Z
eee
jd�dd��ZdS)	r]a%Metadata about a message.

    Args:
        fields (Tuple[~.fields.Field]): The fields declared on the message.
        package (str): The proto package.
        full_name (str): The full name of the message.
        file_info (~._FileInfo): The file descriptor and messages for the
            file containing this message.
        marshal (~.Marshal): The marshal instance to which this message was
            automatically registered.
        options (~.descriptor_pb2.MessageOptions): Any options that were
            set on the message.
    N)r4r(r5r6r0r�cCsN||_||_||_t�dd�|D��|_t�dd�|D��|_||_d|_dS)Ncss|]}|j|fVqdS)N)r)r,r-rrrrw�sz(_MessageInfo.__init__.<locals>.<genexpr>css|]}|j|fVqdS)N)r!)r,r-rrrrw�s)	r(r5r0rFrGr4Zfields_by_numberr6r�)r}r4r(r5r6r0rrrr��s	z_MessageInfo.__init__)r�cCs|jS)z�Return the protobuf message type for this descriptor.

        If a field on the message references another message which has not
        loaded, then this method returns None.
        )r�)r}rrrr)�sz_MessageInfo.pb)r�rrr�rrrNrrrXr�r�rrrHr)rrrrr]�s
	r])rH)'rF�collections.abcr�rC�typingrrrr�Zgoogle.protobufZgooglerrZgoogle.protobuf.json_formatrrr	�protor
rZproto.fieldsrr
rZ
proto.marshalrZproto.primitivesrZproto.utilsrZprotobuf�__version__r�r�rUrrHr]�__all__rrrr�<module>s:c5*