U cf@sDddlmZddlZddlZGdddeddZGdddZdS)) namedtupleNcs eZdZdZfddZZS)ExtTypez'ExtType represents ext type in msgpack.csRt|tstdt|ts$tdd|kr8dksBntdt|||S)Nzcode must be intzdata must be bytesrzcode must be 0~127) isinstanceint TypeErrorbytes ValueErrorsuper__new__)clscodedata __class__E/opt/hc_python/lib/python3.8/site-packages/pip/_vendor/msgpack/ext.pyr s  zExtType.__new__)__name__ __module__ __qualname____doc__r __classcell__rrrrrsrz code datac@seZdZdZddgZd ddZddZd d Zd d Zd dZ e ddZ ddZ e ddZ ddZe ddZddZddZe ddZdS)! TimestampaVTimestamp 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 nanosecondsrcCsRt|tstdt|ts$tdd|kr8dksBntd||_||_dS)aInitialize 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)rrrr rr)selfrrrrr__init__s  zTimestamp.__init__cCsd|jd|jdS)z#String representation of Timestamp.zTimestamp(seconds=z, nanoseconds=)rrrrrr__repr__5szTimestamp.__repr__cCs*t||jkr&|j|jko$|j|jkSdS)z0Check for equality with another Timestamp objectF)typerrrrotherrrr__eq__9szTimestamp.__eq__cCs || S)z(not-equals method (see :func:`__eq__()`))r%r#rrr__ne__?szTimestamp.__ne__cCst|j|jfS)N)hashrrr rrr__hash__CszTimestamp.__hash__cCst|dkr"td|d}d}nTt|dkrPtd|d}|d@}|d?}n&t|dkrntd |\}}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)lenstructunpackr r)brrdata64rrr from_bytesFs    zTimestamp.from_bytescCs\|jd?dkrF|jd>|jB}|d@dkr8td|}qXtd|}ntd|j|j}|S)zPack this Timestamp object into bytes. Used for pure-Python msgpack packing. :returns data: Payload for EXT message with code -1 (timestamp type) :rtype: bytes r-rlr*r,r/)rrr1pack)rr4rrrrto_bytesas zTimestamp.to_bytescCs&t|d}t|dd}t||S)zCreate a Timestamp from posix timestamp in seconds. :param unix_float: Posix timestamp in seconds. :type unix_float: int or float r)rr)unix_secrrrrr from_unixvs zTimestamp.from_unixcCs|j|jdS)znGet the timestamp as a floating-point value. :returns: posix timestamp :rtype: float geArr rrrto_unixszTimestamp.to_unixcCstt|dS)zCreate a Timestamp from posix timestamp in nanoseconds. :param int unix_ns: Posix timestamp in nanoseconds. :rtype: Timestamp r)rdivmod)unix_nsrrrfrom_unix_nanoszTimestamp.from_unix_nanocCs|jd|jS)z~Get the timestamp as a unixtime in nanoseconds. :returns: posix timestamp in nanoseconds :rtype: int rrr rrr to_unix_nanoszTimestamp.to_unix_nanocCs&tjj}tjd|tj|dS)zRGet the timestamp as a UTC datetime. :rtype: `datetime.datetime` r)r)datetimetimezoneutc fromtimestamp timedeltar;)rrBrrr to_datetimeszTimestamp.to_datetimecCst|S)zQCreate a Timestamp from datetime with tzinfo. :rtype: Timestamp )rr: timestamp)dtrrr from_datetimeszTimestamp.from_datetimeN)r)rrrr __slots__rr!r%r&r( staticmethodr5r7r:r;r>r?rErHrrrrrs&     r) collectionsrr@r1rrrrrrs