HEX
Server: Apache
System: Linux p102.lithium.hosting 4.18.0-553.141.1.el8_10.x86_64 #1 SMP Fri Jul 10 17:48:02 UTC 2026 x86_64
User: bvzmoamr (9955)
PHP: 8.1.34
Disabled: syslog
Upload Files
File: //usr/lib64/python2.7/site-packages/mercurial/thirdparty/cbor/cbor2/encoder.pyo
�
1�3\c@sXddlZddlZddlmZmZddlmZddlmZddl	m	Z	m
Z
mZddlm
Z
ddlmZmZmZmZmZmZmZmZdd	lmZmZmZd
efd��YZd�Zd
�Zd�Zd�Z d�Z!d�Z"ed��Z#ed��Z$d�Z%ed��Z&d�Z'd�Z(d�Z)d�Z*d�Z+d�Z,d�Z-d�Z.d�Z/d�Z0d �Z1d!�Z2d"�Z3d#�Z4d$�Z5d%�Z6ee7e fe8e!fee"fe9efeefe:e2fd3e*fe;e4fe<d�e5fe>e#fe?e#fe@e$fee$fee$fe<e�e6fe	e(fe
e)fe<ejAd(��e,fd4e+fd5e-fd6e.fee1fee'feBe/feCe/fg�ZDee:e3fe@e&fee&fee&feBe0feCe0fg�ZEd/eFfd0��YZGd1�ZHd2�ZIdS(7i����N(tOrderedDicttdefaultdict(tcontextmanager(twraps(tdatetimetdatettime(tBytesIOi(t	iteritemsttimezonetlongtunicodet
as_unicodetbytes_from_listtpack_float16tunpack_float16(tCBORTagt	undefinedtCBORSimpleValuetCBOREncodeErrorcBseZdZRS(sORaised when an error occurs while serializing an object into a CBOR datastream.(t__name__t
__module__t__doc__(((sM/usr/lib64/python2.7/site-packages/mercurial/thirdparty/cbor/cbor2/encoder.pyRscst���fd��}|S(s�
    Wrap the given encoder function to gracefully handle cyclic data structures.

    If value sharing is enabled, this marks the given value shared in the datastream on the
    first call. If the value has already been passed to this method, a reference marker is
    instead written to the data stream and the wrapped function is not called.

    If value sharing is disabled, only infinite recursion protection is done.

    cs�t|�}|jj|d�\}}|jr�||krb|jtdd��t||�q�|t|j�f|j|<|jtdd���||||�nK||kr�t	d��n0|df|j|<�||||�|j|=dS(Ni�iis<cyclic data structure detected but value sharing is disabled(NN(
tidt_shared_containerstgettNonet
value_sharingtwritet
encode_lengtht
encode_inttlenR(tencodertvaluetargstkwargstvalue_idt	containertcontainer_index(tfunc(sM/usr/lib64/python2.7/site-packages/mercurial/thirdparty/cbor/cbor2/encoder.pytwrappers	(R(R'R(((R'sM/usr/lib64/python2.7/site-packages/mercurial/thirdparty/cbor/cbor2/encoder.pytshareable_encoderscCs�|dkr tjd||B�S|dkrCtjd|dB|�S|dkrftjd|dB|�S|dkr�tjd	|d
B|�Stjd|dB|�SdS(
Nis>Bis>BBis>BHiIs>BLis>BQi(tstructtpack(t	major_tagtlength((sM/usr/lib64/python2.7/site-packages/mercurial/thirdparty/cbor/cbor2/encoder.pyR7scCs�|dks|dkr�|dkr-d}nd}|d}g}x5|dkr{t|d�\}}|jd|�qGWt|�}t|t||��nE|dkr�|jtd|��n |jtdt|�d��dS(	Nll����iiiiii (tdivmodtinsertR
tencode_semanticRRRtabs(R R!t
major_typetvaluest	remaindertpayload((sM/usr/lib64/python2.7/site-packages/mercurial/thirdparty/cbor/cbor2/encoder.pyRDs	cCs$|jtdt|��|�dS(Ni@(RRR(R R!((sM/usr/lib64/python2.7/site-packages/mercurial/thirdparty/cbor/cbor2/encoder.pytencode_bytestringZscCst|t|��dS(N(R6tbytes(R R!((sM/usr/lib64/python2.7/site-packages/mercurial/thirdparty/cbor/cbor2/encoder.pytencode_bytearray^scCs3|jd�}|jtdt|��|�dS(Nsutf-8i`(tencodeRRR(R R!tencoded((sM/usr/lib64/python2.7/site-packages/mercurial/thirdparty/cbor/cbor2/encoder.pyt
encode_stringbscCs>|jtdt|���x|D]}|j|�q#WdS(Ni�(RRRR9(R R!titem((sM/usr/lib64/python2.7/site-packages/mercurial/thirdparty/cbor/cbor2/encoder.pytencode_arraygs
cCsW|jtdt|���x4t|�D]&\}}|j|�|j|�q)WdS(Ni�(RRRRR9(R R!tkeytval((sM/usr/lib64/python2.7/site-packages/mercurial/thirdparty/cbor/cbor2/encoder.pyt
encode_mapns
cCs|j|�}t|�|fS(sHTakes a key and calculates the length of its optimal byte representation(tencode_to_bytesR(R R!R:((sM/usr/lib64/python2.7/site-packages/mercurial/thirdparty/cbor/cbor2/encoder.pytencode_sortable_keyvscs{�fd�|j�D�}�jtdt|���x<t|�D].\}}�j|d��j||�qEWdS(s6Reorder keys according to Canonical CBOR specificationc3s$|]}t�|�|fVqdS(N(RB(t.0R>(R (sM/usr/lib64/python2.7/site-packages/mercurial/thirdparty/cbor/cbor2/encoder.pys	<genexpr>si�iN(tkeysRRRtsortedR9(R R!t
keyed_keystsortkeytrealkey((R sM/usr/lib64/python2.7/site-packages/mercurial/thirdparty/cbor/cbor2/encoder.pytencode_canonical_map|s
cCs-|jtd|j��|j|j�dS(Ni�(RRttagR9R!(R R!((sM/usr/lib64/python2.7/site-packages/mercurial/thirdparty/cbor/cbor2/encoder.pyR0�scCs�|js9|jr*|jd|j�}q9td��n|jr�ddlm}||j��|jd}t	|t
d|��n4t|j�jdd��}t	|t
d	|��dS(
Nttzinfos?naive datetime encountered and no default timezone has been seti����(ttimegmi@Bis+00:00tZi(
RKR	treplaceRtdatetime_as_timestamptcalendarRLtutctimetupletmicrosecondR0RRt	isoformat(R R!RLt	timestampt
datestring((sM/usr/lib64/python2.7/site-packages/mercurial/thirdparty/cbor/cbor2/encoder.pytencode_datetime�s			cCs5tj|t��jdtj�}t||�dS(NRK(RtcombineRRNR	tutcRV(R R!((sM/usr/lib64/python2.7/site-packages/mercurial/thirdparty/cbor/cbor2/encoder.pytencode_date�s$c
Cs�|j�r|jd�n�|j�rJ|j|dkr@dnd�nc|j�}td�tt|j��D��}|j��$t	|t
d|j|g��WdQXdS(Ns�~is�|s��css#|]\}}|d|VqdS(i
N((RCtitd((sM/usr/lib64/python2.7/site-packages/mercurial/thirdparty/cbor/cbor2/encoder.pys	<genexpr>�si(tis_nanRtis_infinitetas_tupletsumt	enumeratetreversedtdigitstdisable_value_sharingR0Rtexponent(R R!tdttmantissa((sM/usr/lib64/python2.7/site-packages/mercurial/thirdparty/cbor/cbor2/encoder.pytencode_decimal�s"%
c
Cs9|j��'t|td|j|jg��WdQXdS(Ni(RcR0Rt	numeratortdenominator(R R!((sM/usr/lib64/python2.7/site-packages/mercurial/thirdparty/cbor/cbor2/encoder.pytencode_rational�s
cCs#t|tdt|j���dS(Ni#(R0RRtpattern(R R!((sM/usr/lib64/python2.7/site-packages/mercurial/thirdparty/cbor/cbor2/encoder.pyt
encode_regexp�scCs&t|tdt|j����dS(Ni$(R0RRt	as_string(R R!((sM/usr/lib64/python2.7/site-packages/mercurial/thirdparty/cbor/cbor2/encoder.pytencode_mime�scCst|td|j��dS(Ni%(R0RR7(R R!((sM/usr/lib64/python2.7/site-packages/mercurial/thirdparty/cbor/cbor2/encoder.pytencode_uuid�scCs t|tdt|���dS(Ni(R0Rttuple(R R!((sM/usr/lib64/python2.7/site-packages/mercurial/thirdparty/cbor/cbor2/encoder.pyt
encode_set�scCs_tg|D]}t||�|f^q
�}t|tdg|D]}|d^qA��dS(Nii(RERBR0R(R R!R>R3((sM/usr/lib64/python2.7/site-packages/mercurial/thirdparty/cbor/cbor2/encoder.pytencode_canonical_set�s.cCsU|jdkr2|jtjdd|jB��n|jtjdd|j��dS(Nis>Bi�s>BBi�(R!RR*R+(R R!((sM/usr/lib64/python2.7/site-packages/mercurial/thirdparty/cbor/cbor2/encoder.pytencode_simple_value�s#cCs|ddl}|j|�r+|jd�nM|j|�r\|j|dkrRdnd�n|jtjdd|��dS(Ni����s�~is�|s��s>Bdi�(tmathtisnanRtisinfR*R+(R R!Rt((sM/usr/lib64/python2.7/site-packages/mercurial/thirdparty/cbor/cbor2/encoder.pytencode_float�s"cCs�ddl}|j|�r+|jd�n�|j|�r\|j|dkrRdnd�n�tjdd|�}tjd|�d|kr�tjd	d
|�}|j|�nEt|�}|r�t|d�|kr�|j|�n
|j|�dS(Ni����s�~is�|s��s>Bfi�is>Bdi�(	RtRuRRvR*R+tunpackRR(R R!RtR:tf16((sM/usr/lib64/python2.7/site-packages/mercurial/thirdparty/cbor/cbor2/encoder.pytencode_minimal_float�s"cCs|j|rdnd�dS(Ns�s�(R(R R!((sM/usr/lib64/python2.7/site-packages/mercurial/thirdparty/cbor/cbor2/encoder.pytencode_boolean�scCs|jd�dS(Ns�(R(R R!((sM/usr/lib64/python2.7/site-packages/mercurial/thirdparty/cbor/cbor2/encoder.pytencode_nonescCs|jd�dS(Ns�(R(R R!((sM/usr/lib64/python2.7/site-packages/mercurial/thirdparty/cbor/cbor2/encoder.pytencode_undefinedstdecimaltDecimaltt	fractionstFractions
email.messagetMessagetuuidtUUIDtCBOREncodercBs_eZdZdZededed	�Zd
�Zed��Z	d�Z
d
�Zd�ZRS(s�
    Serializes objects to a byte stream using Concise Binary Object Representation.

    :param datetime_as_timestamp: set to ``True`` to serialize datetimes as UNIX timestamps
        (this makes datetimes more concise on the wire but loses the time zone information)
    :param datetime.tzinfo timezone: the default timezone to use for serializing naive datetimes
    :param value_sharing: if ``True``, allows more efficient serializing of repeated values and,
        more importantly, cyclic data structures, at the cost of extra line overhead
    :param default: a callable that is called by the encoder with three arguments
        (encoder, value, file object) when no suitable encoder has been found, and should use the
        methods on the encoder to encode any objects it wants to add to the data stream
    :param canonical: Forces mapping types to be output in a stable order to guarantee that the
        output will always produce the same hash given the same input.
    tfpROR	tdefaultRtjson_compatibleRt	_encoderscCsb||_||_||_||_||_i|_tj�|_|r^|jj	t
�ndS(N(R�ROR	RR�Rtdefault_encoderstcopyR�tupdatetcanonical_encoders(tselfR�ROR	RR�t	canonical((sM/usr/lib64/python2.7/site-packages/mercurial/thirdparty/cbor/cbor2/encoder.pyt__init__Bs						cCs�ddlm}x�tt|j��D]�\}}t|�tkr�|\}}t|j|�|d�}|dk	r&|j|=||j|<|}q�q&nt
||�r&||j|<|Sq&WdS(Ni����(tmodules(tsysR�tlistRR�ttypeRptgetattrRRt
issubclass(R�tobj_typeR�ttype_tenctmodnamettypenamet
imported_type((sM/usr/lib64/python2.7/site-packages/mercurial/thirdparty/cbor/cbor2/encoder.pyt
_find_encoderNs"

	
ccs$|j}t|_dV||_dS(sKDisable value sharing in the encoder for the duration of the context block.N(RtFalse(R�told_value_sharing((sM/usr/lib64/python2.7/site-packages/mercurial/thirdparty/cbor/cbor2/encoder.pyRcbs		cCs|jj|�dS(s[
        Write bytes to the data stream.

        :param data: the bytes to write

        N(R�R(R�tdata((sM/usr/lib64/python2.7/site-packages/mercurial/thirdparty/cbor/cbor2/encoder.pyRjscCs`|j}|jj|�p0|j|�p0|j}|sOtd|j��n|||�dS(s`
        Encode the given object using CBOR.

        :param obj: the object to encode

        scannot serialize type %sN(t	__class__R�RR�R�RR(R�tobjR�R ((sM/usr/lib64/python2.7/site-packages/mercurial/thirdparty/cbor/cbor2/encoder.pyR9ss
	*cCs9|j}t�|_}|j|�||_|j�S(s,
        Encode the given object to a byte buffer and return its value as bytes.

        This method was intended to be used from the ``default`` hook when an object needs to be
        encoded separately from the rest but while still taking advantage of the shared value
        registry.

        (R�RR9tgetvalue(R�R�told_fpR�((sM/usr/lib64/python2.7/site-packages/mercurial/thirdparty/cbor/cbor2/encoder.pyRA�s
		
	(R�ROR	R�RR�RR�N(
RRRt	__slots__R�RR�R�RRcRR9RA(((sM/usr/lib64/python2.7/site-packages/mercurial/thirdparty/cbor/cbor2/encoder.pyR�/s					cKs#t�}t|||�|j�S(s�
    Serialize an object to a bytestring.

    :param obj: the object to serialize
    :param kwargs: keyword arguments passed to :class:`~.CBOREncoder`
    :return: the serialized output
    :rtype: bytes

    (RtdumpR�(R�R#R�((sM/usr/lib64/python2.7/site-packages/mercurial/thirdparty/cbor/cbor2/encoder.pytdumps�s
	cKst||�j|�dS(s�
    Serialize an object to a file.

    :param obj: the object to serialize
    :param fp: a file-like object
    :param kwargs: keyword arguments passed to :class:`~.CBOREncoder`

    N(R�R9(R�R�R#((sM/usr/lib64/python2.7/site-packages/mercurial/thirdparty/cbor/cbor2/encoder.pyR��s	(R~R(R�R�(s
email.messageR�(R�R�(JtreR*tcollectionsRRt
contextlibRt	functoolsRRRRtioRtcompatRR	R
RRR
RRttypesRRRt	ExceptionRR)RRR6R8R;R=R@RBRIR0RVRYRgRjRlRnRoRqRrRsRwRzR{R|R}R7t	bytearraytinttfloattboolR�RRpR�tdicttcompiletsett	frozensetR�R�tobjectR�R�R�(((sM/usr/lib64/python2.7/site-packages/mercurial/thirdparty/cbor/cbor2/encoder.pyt<module>s�:	%	
					
					
						
																																b