File: //usr/local/lib/python3.10/dist-packages/pip/_vendor/msgpack/__pycache__/ext.cpython-310.pyc
o
��h^ � @ sD d dl Z d dlZd dlmZ G dd� dedd��ZG dd� d�ZdS )� N)�
namedtuplec s e Zd ZdZ� fdd�Z� ZS )�ExtTypez'ExtType represents ext type in msgpack.c sX t |t�s td��t |t�std��d| krdks$td�� td��t� �| ||�S )Nzcode must be intzdata must be bytesr � zcode must be 0~127)�
isinstance�int� TypeError�bytes�
ValueError�super�__new__)�cls�code�data�� __class__� �B/usr/local/lib/python3.10/dist-packages/pip/_vendor/msgpack/ext.pyr s
�zExtType.__new__)�__name__�
__module__�__qualname__�__doc__r �
__classcell__r r r r r s r z code datac @ s� e Zd ZdZddgZd dd�Zdd� Zd d
� Zdd� Zd
d� Z e
dd� �Zdd� Ze
dd� �Z
dd� Ze
dd� �Zdd� Zdd� Ze
dd� �ZdS )!� TimestampaV Timestamp 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�nanosecondsr c C sX t |t�s td��t |t�std��d| krdk s$td�� td��|| _|| _dS )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 neg. seconds + pos. ns.
zseconds must be an integerznanoseconds must be an integerr � ʚ;z?nanoseconds must be a non-negative integer less than 999999999.N)r r r r r r )�selfr r r r r �__init__ s
�
zTimestamp.__init__c C s d| j � d| j� d�S )z#String representation of Timestamp.zTimestamp(seconds=z, nanoseconds=�)�r r �r r r r �__repr__5 s zTimestamp.__repr__c C s* t |�| ju r| j|jko| j|jkS dS )z0Check for equality with another Timestamp objectF)�typer r r �r �otherr r r �__eq__9 s zTimestamp.__eq__c C s | � |� S )z(not-equals method (see :func:`__eq__()`))r% r# r r r �__ne__? s zTimestamp.__ne__c C s t | j| jf�S )N)�hashr r r r r r �__hash__C s zTimestamp.__hash__c C s� t | �dkrt�d| �d }d}n*t | �dkr(t�d| �d }|d@ }|d? }nt | �dkr7t�d | �\}}ntd
��t||�S )a Unpack 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 �� �"