3 ”Re’ã@s¤ddlmZddlZddlZddlZejddkZerDeefZ dZ n6eZ y ej j Z Wn$e k rxej ejdƒƒZ YnXGdd„deddƒƒZGdd„deƒZdS) é)Ú namedtupleNécs eZdZdZ‡fdd„Z‡ZS)ÚExtTypez'ExtType represents ext type in msgpack.csXt|tƒstdƒ‚t|tƒs$tdƒ‚d|ko6dknsDtdƒ‚tt|ƒj|||ƒS)Nzcode must be intzdata must be bytesrézcode must be 0~127)Ú isinstanceÚintÚ TypeErrorÚbytesÚ ValueErrorÚsuperrÚ__new__)ÚclsÚcodeÚdata)Ú __class__©ú†/builddir/build/BUILDROOT/alt-python36-pip-20.2.4-5.el8.x86_64/opt/alt/python36/lib/python3.6/site-packages/pip/_vendor/msgpack/ext.pyr s  zExtType.__new__)Ú__name__Ú __module__Ú __qualname__Ú__doc__r Ú __classcell__rr)rrrsrz code datac@s’eZdZdZddgZd dd„Zdd„Zd d „Zd d „Zd d„Z e dd„ƒZ dd„Z e dd„ƒZ dd„Ze dd„ƒZdd„Zdd„Ze dd„ƒZdS)!Ú 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Ú nanosecondsrcCsTt|tƒstdƒ‚t|tƒs$tdƒ‚d|ko6dknsDtdƒ‚||_||_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 negative seconds + positive ns. zseconds must be an intergerznanoseconds must be an integerré é z?nanoseconds must be a non-negative integer less than 999999999.NiÊš;)rÚ int_typesrr rr)ÚselfrrrrrÚ__init__-s  zTimestamp.__init__cCsdj|j|jƒS)z#String representation of Timestamp.z'Timestamp(seconds={0}, nanoseconds={1}))Úformatrr)rrrrÚ__repr__EszTimestamp.__repr__cCs*t|ƒ|jkr&|j|jko$|j|jkSdS)z0Check for equality with another Timestamp objectF)Útyperrr)rÚotherrrrÚ__eq__KszTimestamp.__eq__cCs |j|ƒ S)z(not-equals method (see :func:`__eq__()`))r$)rr#rrrÚ__ne__SszTimestamp.__ne__cCst|j|jfƒS)N)Úhashrr)rrrrÚ__hash__WszTimestamp.__hash__cCs€t|ƒdkr"tjd|ƒd}d}nTt|ƒdkrPtjd|ƒd}|d@}|d?}n&t|ƒdkrntjd |ƒ\}}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 éz!Lréz!Qlÿÿé"é z!IqzFTimestamp type can only be created from 32, 64, or 96-bit byte objects)ÚlenÚstructÚunpackr r)ÚbrrÚdata64rrrÚ from_bytesZs    zTimestamp.from_bytescCs\|jd?dkrF|jd>|jB}|d@dkr8tjd|ƒ}qXtjd|ƒ}ntjd|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 r*rlüÿz!Lz!Qz!Iq)rrr-Úpack)rr0rrrrÚto_bytesus zTimestamp.to_bytescCs&t|dƒ}t|ddƒ}t||ƒS)zœCreate a Timestamp from posix timestamp in seconds. :param unix_float: Posix timestamp in seconds. :type unix_float: int or float. érriÊš;)rr)Úunix_secrrrrrÚ from_unixŠs zTimestamp.from_unixcCs|j|jdS)znGet the timestamp as a floating-point value. :returns: posix timestamp :rtype: float geÍÍA)rr)rrrrÚto_unix•szTimestamp.to_unixcCstt|dƒŽS)z—Create a Timestamp from posix timestamp in nanoseconds. :param int unix_ns: Posix timestamp in nanoseconds. :rtype: Timestamp rriÊš;)rÚdivmod)Úunix_nsrrrÚfrom_unix_nano�szTimestamp.from_unix_nanocCs|jd|jS)z~Get the timestamp as a unixtime in nanoseconds. :returns: posix timestamp in nanoseconds :rtype: int rriÊš;)rr)rrrrÚ to_unix_nano¦szTimestamp.to_unix_nanocCstjj|jƒtƒS)zlGet the timestamp as a UTC datetime. Python 2 is not supported. :rtype: datetime. )ÚdatetimeÚ fromtimestampr7Ú_utc)rrrrÚ to_datetime®szTimestamp.to_datetimecCstj|jƒƒS)zuCreate a Timestamp from datetime with tzinfo. Python 2 is not supported. :rtype: Timestamp )rr6Ú timestamp)ÚdtrrrÚ from_datetime·szTimestamp.from_datetimeN)r)rrrrÚ __slots__rr!r$r%r'Ú staticmethodr1r3r6r7r:r;r?rBrrrrr"s     r)Ú collectionsrr<Úsysr-Ú version_infoÚPY2rÚlongrr>ÚtimezoneÚutcÚAttributeErrorÚ timedeltarÚobjectrrrrrÚs