Viewing File: /opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/msgpack/__pycache__/ext.cpython-35.pyc



t_@sddlmZddlZddlZddlZejddkZerbeefZ	dZ
nCeZ	yejjZ
Wn*e
k
rejejdZ
YnXGdddeddZGdddeZdS)	)
namedtupleNcs(eZdZdZfddZS)ExtTypez'ExtType represents ext type in msgpack.cszt|tstdt|ts6tdd|koMdkns^tdtt|j|||S)Nzcode must be intzdata must be bytesrzcode must be 0~127)
isinstanceint	TypeErrorbytes
ValueErrorsuperr__new__)clscodedata)	__class__/builddir/build/BUILDROOT/alt-python35-pip-20.2.4-1.el7.x86_64/opt/alt/python35/lib/python3.5/site-packages/pip/_vendor/msgpack/ext.pyrszExtType.__new__)__name__
__module____qualname____doc__rrr)rrrsrz	code datac@seZdZdZddgZdddZddZd	d
ZddZd
dZ	e
ddZddZe
ddZ
ddZe
ddZddZddZe
ddZdS) 	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.
    secondsnanosecondsrcCstt|tstdt|ts6tdd|koMdkns^td||_||_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 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|jS)z#String representation of Timestamp.z'Timestamp(seconds={0}, nanoseconds={1}))formatrr)rrrr__repr__EszTimestamp.__repr__cCs;t||jkr7|j|jko6|j|jkSdS)z0Check for equality with another Timestamp objectF)typerrr)rotherrrr__eq__Ks"zTimestamp.__eq__cCs|j|S)z(not-equals method (see :func:`__eq__()`))r#)rr"rrr__ne__SszTimestamp.__ne__cCst|j|jfS)N)hashrr)rrrr__hash__WszTimestamp.__hash__cCst|dkr1tjd|d}d}nxt|dkrptjd|d}|d@}|d?}n9t|dkrtjd	|\}}ntd
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!Lrz!Ql"z!IqzFTimestamp type can only be created from 32, 64, or 96-bit byte objects)lenstructunpackr
r)brrdata64rrr
from_bytesZs	

	zTimestamp.from_bytescCs|jd?dkra|jd>|jB}|d@dkrLtjd|}q|tjd|}ntjd|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)rlz!Lz!Qz!Iq)rrr,pack)rr/rrrrto_bytesuszTimestamp.to_bytescCs1t|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.
        rriʚ;)rr)unix_secrrrrr	from_unixszTimestamp.from_unixcCs|j|jdS)znGet the timestamp as a floating-point value.

        :returns: posix timestamp
        :rtype: float
        geA)rr)rrrrto_unixszTimestamp.to_unixcCstt|dS)zCreate a Timestamp from posix timestamp in nanoseconds.

        :param int unix_ns: Posix timestamp in nanoseconds.
        :rtype: Timestamp
        rriʚ;)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
        rriʚ;)rr)rrrrto_unix_nanoszTimestamp.to_unix_nanocCstjj|jtS)zlGet the timestamp as a UTC datetime.

        Python 2 is not supported.

        :rtype: datetime.
        )datetime
fromtimestampr6_utc)rrrrto_datetimeszTimestamp.to_datetimecCstj|jS)zuCreate a Timestamp from datetime with tzinfo.

        Python 2 is not supported.

        :rtype: Timestamp
        )rr5	timestamp)dtrrr
from_datetimeszTimestamp.from_datetimeN)rrrr	__slots__rr r#r$r&staticmethodr0r2r5r6r9r:r>rArrrrr"s		r)collectionsrr;sysr,version_infoPY2rlongrr=timezoneutcAttributeError	timedeltarobjectrrrrr<module>s	

Back to Directory File Manager