Current File : //usr/lib/python3/dist-packages/pip/_vendor/msgpack/__pycache__/ext.cpython-312.pyc
�

/�g���$�ddlmZddlZddlZddlZej
ddk(ZereefZ	dZ
neZ		ejjZ
Gd�dedd��ZGd�de�Zy#e
$r%ejejd��Z
Y�GwxYw)	�)�
namedtupleN�c�"��eZdZdZ�fd�Z�xZS)�ExtTypez'ExtType represents ext type in msgpack.c����t|t�std��t|t�std��d|cxkrdkst	d��t	d��t
t|�|||�S)Nzcode must be intzdata must be bytesr�zcode must be 0~127)�
isinstance�int�	TypeError�bytes�
ValueError�superr�__new__)�cls�code�data�	__class__s   ��9/usr/lib/python3/dist-packages/pip/_vendor/msgpack/ext.pyrzExtType.__new__so����$��$��.�/�/��$��&��0�1�1��D��C���1�2�2� ��1�2�2��W�c�*�3��d�;�;�)�__name__�
__module__�__qualname__�__doc__r�
__classcell__)rs@rrrs���1�<�<rrz	code datac��eZdZdZddgZdd�Zd�Zd�Zd�Zd�Z	e
d	��Zd
�Ze
d��Z
d�Ze
d
��Zd�Zd�Ze
d��Zy)�	TimestampaRTimestamp represents the Timestamp extension type in msgpack.

    When built with Cython, msgpack uses C methods to pack and unpack `Timestamp`. When using pure-Python
    msgpack, :func:`to_bytes` and :func:`from_bytes` are used to pack and unpack `Timestamp`.

    This class is immutable: Do not override seconds and nanoseconds.
    �seconds�nanosecondsc���t|t�std��t|t�std��d|cxkrdkstd��td��||_||_y)a�Initialize a Timestamp object.

        :param int seconds:
            Number of seconds since the UNIX epoch (00:00:00 UTC Jan 1 1970, minus leap seconds).
            May be negative.

        :param int nanoseconds:
            Number of nanoseconds to add to `seconds` to get fractional time.
            Maximum is 999_999_999.  Default is 0.

        Note: Negative times (before the UNIX epoch) are represented as negative seconds + positive ns.
        zseconds must be an integerznanoseconds must be an integerr�ʚ;z?nanoseconds must be a non-negative integer less than 999999999.N)r	�	int_typesrr
rr)�selfrrs   r�__init__zTimestamp.__init__-ss���'�9�-��8�9�9��+�y�1��<�=�=��[�(�5�(��Q��
�)��Q��
����&��rc�N�dj|j|j�S)z#String representation of Timestamp.z'Timestamp(seconds={0}, nanoseconds={1}))�formatrr�r"s r�__repr__zTimestamp.__repr__Es$��8�?�?��L�L�$�*�*�
�	
rc��t|�|jur4|j|jk(xr|j|jk(Sy)z0Check for equality with another Timestamp objectF)�typerrr�r"�others  r�__eq__zTimestamp.__eq__KsB����;�$�.�.�(�����
�
�-�W�$�2B�2B�e�FW�FW�2W�
�rc�&�|j|�S)z(not-equals method (see :func:`__eq__()`))r,r*s  r�__ne__zTimestamp.__ne__Ss���;�;�u�%�%�%rc�D�t|j|jf�S)N)�hashrrr&s r�__hash__zTimestamp.__hash__Ws���T�\�\�4�#3�#3�4�5�5rc�8�t|�dk(rtjd|�d}d}net|�dk(r$tjd|�d}|dz}|dz	}n3t|�dk(rtjd	|�\}}ntd
��t	||�S)aUnpack bytes into a `Timestamp` object.

        Used for pure-Python msgpack unpacking.

        :param b: Payload from msgpack ext message with code -1
        :type b: bytes

        :returns: Timestamp object unpacked from msgpack ext payload
        :rtype: Timestamp
        ��!Lr��!Ql���"��!IqzFTimestamp type can only be created from 32, 64, or 96-bit byte objects)�len�struct�unpackr
r)�brr�data64s    r�
from_byteszTimestamp.from_bytesZs����q�6�Q�;��m�m�D�!�,�Q�/�G��K�
��V�q�[��]�]�4��+�A�.�F��1�1�G� �B�,�K�
��V�r�\�#)�=�=���#:� �K���X��
���+�.�.rc�(�|jdz	dk(rT|jdz|jz}|dzdk(rtjd|�}|Stjd|�}|Stjd|j|j�}|S)z�Pack this Timestamp object into bytes.

        Used for pure-Python msgpack packing.

        :returns data: Payload for EXT message with code -1 (timestamp type)
        :rtype: bytes
        r7rl��r4r6r9)rrr;�pack)r"r>rs   r�to_byteszTimestamp.to_bytesus���
�L�L�B��1�$��%�%��+�d�l�l�:�F��*�*�a�/��{�{�4��0����	�{�{�4��0�����;�;�u�d�&6�&6����E�D��rc�X�t|dz�}t|dzdz�}t||�S)z�Create a Timestamp from posix timestamp in seconds.

        :param unix_float: Posix timestamp in seconds.
        :type unix_float: int or float.
        �r )r
r)�unix_secrrs   r�	from_unixzTimestamp.from_unix�s2���h�!�m�$���8�a�<�5�0�1����+�.�.rc�:�|j|jdzzS)znGet the timestamp as a floating-point value.

        :returns: posix timestamp
        :rtype: float
        ge��A�rrr&s r�to_unixzTimestamp.to_unix�s���|�|�d�.�.��4�4�4rc�&�tt|d��S)z�Create a Timestamp from posix timestamp in nanoseconds.

        :param int unix_ns: Posix timestamp in nanoseconds.
        :rtype: Timestamp
        r )r�divmod)�unix_nss r�from_unix_nanozTimestamp.from_unix_nano�s���&��%�0�1�1rc�:�|jdz|jzS)z~Get the timestamp as a unixtime in nanoseconds.

        :returns: posix timestamp in nanoseconds
        :rtype: int
        r rHr&s r�to_unix_nanozTimestamp.to_unix_nano�s���|�|�e�#�d�&6�&6�6�6rc��tjjdt�tj|j	���zS)zlGet the timestamp as a UTC datetime.

        Python 2 is not supported.

        :rtype: datetime.
        r)r)�datetime�
fromtimestamp�_utc�	timedeltarIr&s r�to_datetimezTimestamp.to_datetime�s:��� � �.�.�q�$�7�(�:L�:L��L�L�N�;
�
�	
rc�H�tj|j��S)zuCreate a Timestamp from datetime with tzinfo.

        Python 2 is not supported.

        :rtype: Timestamp
        )rrF�	timestamp)�dts r�
from_datetimezTimestamp.from_datetime�s���"�"�2�<�<�>�2�2rN)r)rrrr�	__slots__r#r'r,r.r1�staticmethodr?rBrFrIrMrOrUrY�rrrr"s�����M�*�I�'�0
��&�6��/��/�4�*�/��/�5��2��2�7�	
��3��3rr)�collectionsrrQ�sysr;�version_info�PY2r
�longr!rS�timezone�utc�AttributeErrorrTr�objectrr\rr�<module>rfs���"��
�
�
���q��Q�����d��I��D��I�8�� � �$�$��

<�j��K�0�
<�_3��_3��#�8� �x� � �!3��!3�!3�A�!6�7��8�s�A%�%'B�B