403Webshell
Server IP : 80.87.202.40  /  Your IP : 216.73.216.169
Web Server : Apache
System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64
User : bitrix ( 600)
PHP Version : 8.2.27
Disable Function : NONE
MySQL : OFF |  cURL : ON |  WGET : ON |  Perl : ON |  Python : OFF |  Sudo : ON |  Pkexec : ON
Directory :  /lib64/python3.9/site-packages/mercurial/utils/__pycache__/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /lib64/python3.9/site-packages/mercurial/utils/__pycache__/cborutil.cpython-39.pyc
a

�+�bE��@sBddlmZddlZddlZddlmZdZdZdZdZ	dZ
dZd	Zd
Z
dZdZd
ZdZdZdZdZdZdZe�ded>eB�Ze�de
d>eB�Ze�ded>eB�Ze�d�Ze�d�Ze�d�Ze�d�Ze�d�Z dZ!dZ"dd�Z#dd�Z$dd�Z%dLd!d"�Z&d#d$�Z'd%d&�Z(d'd(�Z)d)d*�Z*d+d,�Z+d-d.�Z,d/d0�Z-d1d2�Z.d3d4�Z/e0e$e1e'ej2e'e3e(e4e(e5e,e6e+e7e.e8d�e/i	Z9d5d6�Z:Gd7d8�d8e;�Z<ej=j>dk�r�d9d:�Z?nd;d:�Z?e�d�Z@e�d<�ZAe�d=�ZBe�d>�ZCdZDdZEdZFdZGdZHdZIdMd?d@�ZJdNdBdC�ZKGdDdE�dEe0�ZLGdFdG�dGeM�ZNGdHdI�dIeM�ZOdJdK�ZPdS)O�)�absolute_importN�)�pycompat�������������iz>Bz>BBz>BHz>BLz>BQ���cCs�|dkrt�|d>|B�S|dkr6t�|d>dB|�S|dkrRt�|d>dB|�S|dkrnt�|d>dB|�St�|d>dB|�Sd	S)
z6Obtain a value encoding the major type and its length.�r��rlrrN)�ENCODED_LENGTH_1�pack�ENCODED_LENGTH_2�ENCODED_LENGTH_3�ENCODED_LENGTH_4�ENCODED_LENGTH_5)�	majortype�length�r�>/usr/lib64/python3.9/site-packages/mercurial/utils/cborutil.py�encodelengthEsr!ccsttt|��V|VdS�N)r!�MAJOR_TYPE_BYTESTRING�len��vrrr �streamencodebytestringSsr'ccs0tV|D]}ttt|��V|Vq
tVdS)z�Convert an iterator of chunks to an indefinite bytestring.

    Given an input that is iterable and each element in the iterator is
    representable as bytes, emit an indefinite length bytestring.
    N)�BEGIN_INDEFINITE_BYTESTRINGr!r#r$�BREAK)�it�chunkrrr �streamencodebytestringfromiterXs
r,rccsZtVd}t|�}||||�}|t|�7}ttt|��V|V||krqPqtVdS)z�Given a large source buffer, emit as an indefinite length bytestring.

    This is a generator of chunks constituting the encoded CBOR data.
    rN)r(r$r!r#r))�sourceZ	chunksize�i�lr+rrr � streamencodeindefinitebytestringgsr0ccsF|dks|dkrtd��|dkr.tt|�Vnttt|�d�VdS)Nll����sbig integers not supportedrr)�
ValueErrorr!�MAJOR_TYPE_UINT�MAJOR_TYPE_NEGINT�absr%rrr �streamencodeint~s
r5ccs2ttt|��V|D]}t|�D]
}|Vq qdS)z)Encode a known size iterable to an array.N)r!�MAJOR_TYPE_ARRAYr$�streamencode)r/r.r+rrr �streamencodearray�sr8ccs.tV|D]}t|�D]
}|Vqq
tVdS)z:Encode an iterator of items to an indefinite length array.N)�BEGIN_INDEFINITE_ARRAYr7r))r*r.r+rrr �streamencodearrayfromiter�s

r:cCst|�j|fSr")�type�__name__r%rrr �_mixedtypesortkey�sr=ccs,ttt�Vtt|td��D]
}|VqdS)N��key)r!�MAJOR_TYPE_SEMANTIC�SEMANTIC_TAG_FINITE_SETr8�sortedr=)�sr+rrr �streamencodeset�srDccs\ttt|��Vtt�|�dd�d�D]0\}}t|�D]
}|Vq6t|�D]
}|VqJq&dS)z_Encode dictionary to a generator.

    Does not supporting indefinite length dictionaries.
    cSst|d�S�Nr)r=)�xrrr �<lambda>��z!streamencodemap.<locals>.<lambda>r>N)r!�MAJOR_TYPE_MAPr$rBrZ	iteritemsr7)�dr?�valuer+rrr �streamencodemap�s�rLccsFtV|D]0\}}t|�D]
}|Vqt|�D]
}|Vq.q
tVdS)zFGiven an iterable of (key, value), encode to an indefinite length map.N)�BEGIN_INDEFINITE_MAPr7r))r*r?rKr+rrr �streamencodemapfromiter�s
rNccs|rdndVdS)N����r)�brrr �streamencodebool�srRccs
dVdS)N��rr%rrr �streamencodenone�srTcCsNt�|j�}|s2tD]}t||�s$qt|}q2q|sFtdt|���||�S)a1Encode a value in a streaming manner.

    Given an input object, encode it to CBOR recursively.

    Returns a generator of CBOR encoded bytes. There is no guarantee
    that each emitted chunk fully decodes to a value or sub-value.

    Encoding is deterministic - unordered collections are sorted.
    sdo not know how to encode %s)�STREAM_ENCODERS�get�	__class__�
isinstancer1r;)r&�fn�tyrrr r7�s

r7c@seZdZdZdS)�CBORDecodeErrorz"Represents an error decoding CBOR.N)r<�
__module__�__qualname__�__doc__rrrr r[�sr[cCs||Sr"r�rQr.rrr �_elementtointeger�sr`cCst||�Sr")�ordr_rrr r`ss>Hs>Ls>Qc
Cst||�}|d7}|d?}|t@}|tkr`t|||�\}}}|rPd||dtfSdd|tfS�n�|tkr�t|||�\}}}|r�d|d|dtfSdd|tfS�nt|tk�rRt|||dd�\}}}|s�dd|tfS|du�rB|||t|�k�r ||||||�}d|||dtfSt|�|||}	dd|	tfSndddtfS�n�|t	k�rht
d���n�|tk�r�t|||�\}}}|�r�d||dtfSdd|tfS�nn|t
k�r�t|||�\}}}|�r�d||dtfSdd|tfS�n,|tk�r�t|||�\}}
}|�sdd|tfS|
tk�r�||t|�k�rBdddtfSt|||�\}}}}|�sjdd|tfS|tk�r|t
d	��d|||dtfSt
d
|
��nz|tk�r|tk�r�dddtfS|tk�r�dddtfS|tk�r�dddtfS|tk�rdddtfSt
d|��n
d�sJ�dS)a�Decode a new CBOR value from a buffer at offset.

    This function attempts to decode up to one complete CBOR value
    from ``b`` starting at offset ``offset``.

    The beginning of a collection (such as an array, map, set, or
    indefinite length bytestring) counts as a single value. For these
    special cases, a state flag will indicate that a special value was seen.

    When called, the function either returns a decoded value or gives
    a hint as to how many more bytes are needed to do so. By calling
    the function repeatedly given a stream of bytes, the caller can
    build up the original values.

    Returns a tuple with the following elements:

    * Bool indicating whether a complete value was decoded.
    * A decoded value if first value is True otherwise None
    * Integer number of bytes. If positive, the number of bytes
      read. If negative, the number of bytes we need to read to
      decode this value or the next chunk in this value.
    * One of the ``SPECIAL_*`` constants indicating special treatment
      for this value. ``SPECIAL_NONE`` means this is a fully decoded
      simple value (such as an integer or bool).
    rrTFN)�allowindefinitesstring major type not supported���s,expected array after finite set semantic tagssemantic tag %d not allowedsspecial type %d not allowed)r`�SUBTYPE_MASKr2�
decodeuint�SPECIAL_NONEr3r#r$�#SPECIAL_START_INDEFINITE_BYTESTRING�MAJOR_TYPE_STRINGr[r6�SPECIAL_START_ARRAYrI�SPECIAL_START_MAPr@rA�
decodeitem�SPECIAL_START_SET�MAJOR_TYPE_SPECIAL�
SUBTYPE_FALSE�SUBTYPE_TRUE�SUBTYPE_NULL�SUBTYPE_INDEFINITE�SPECIAL_INDEFINITE_BREAK)
rQ�offset�initialr�subtype�completerK�	readcount�size�wantedZtagvalueZ
readcount2�specialrrr rks�

�




	
�
�




rkFcCs�|dkrd|dfS|dkr,|r"dStd��n|dkr@td|��|dkrNt}n2|d	kr\t}n$|d
krjt}n|dkrxt}ntd��t|�||jkr�d|�||�d|jfSd
dt|�||jfSdS)aDecode an unsigned integer.

    ``subtype`` is the lower 5 bits from the initial byte CBOR item
    "header." ``b`` is a buffer containing bytes. ``offset`` points to
    the index of the first byte after the byte that ``subtype`` was
    derived from.

    ``allowindefinite`` allows the special indefinite length value
    indicator.

    Returns a 3-tuple of (successful, value, count).

    The first element is a bool indicating if decoding completed. The 2nd
    is the decoded integer value or None if not fully decoded or the subtype
    is 31 and ``allowindefinite`` is True. The 3rd value is the count of bytes.
    If positive, it is the number of additional bytes decoded. If negative,
    it is the number of additional bytes needed to decode this value.
    rTrr)TNrs'indefinite length uint not allowed here�s'unsupported subtype on integer type: %drrrs#bounds condition checking violationFN)r[�STRUCT_BIG_UBYTE�STRUCT_BIG_USHORT�STRUCT_BIG_ULONG�STRUCT_BIG_ULONGLONGr$rx�unpack_from)rurQrsrbrCrrr re�s,

�rec@seZdZdZddd�ZdS)�bytestringchunkaRepresents a chunk/segment in an indefinite length bytestring.

    This behaves like a ``bytes`` but in addition has the ``isfirst``
    and ``islast`` attributes indicating whether this chunk is the first
    or last in an indefinite length bytestring.
    FcCst�||�}||_||_|Sr")�bytes�__new__ZisfirstZislast)�clsr&�first�last�selfrrr r��szbytestringchunk.__new__N)FF)r<r\r]r^r�rrrr r��sr�c@sReZdZdZdZdZdZdZdZdZ	dZ
d	d
�Zedd��Z
dd
d�Zdd�ZdS)�
sansiodecodera�A CBOR decoder that doesn't perform its own I/O.

    To use, construct an instance and feed it segments containing
    CBOR-encoded bytes via ``decode()``. The return value from ``decode()``
    indicates whether a fully-decoded value is available, how many bytes
    were consumed, and offers a hint as to how many bytes should be fed
    in next time to decode the next value.

    The decoder assumes it will decode N discrete CBOR values, not just
    a single value. i.e. if the bytestream contains uints packed one after
    the other, the decoder will decode them all, rather than just the initial
    one.

    When ``decode()`` indicates a value is available, call ``getavailable()``
    to return all fully decoded values.

    ``decode()`` can partially decode input. It is up to the caller to keep
    track of what data was consumed and to pass unconsumed data in on the
    next invocation.

    The decoder decodes atomically at the *item* level. See ``decodeitem()``.
    If an *item* cannot be fully decoded, the decoder won't record it as
    partially consumed. Instead, the caller will be instructed to pass in
    the initial bytes of this item on the next invocation. This does result
    in some redundant parsing. But the overhead should be minimal.

    This decoder only supports a subset of CBOR as required by Mercurial.
    It lacks support for:

    * Indefinite length arrays
    * Indefinite length maps
    * Use of indefinite length bytestrings as keys or values within
      arrays, maps, or sets.
    * Nested arrays, maps, or sets within sets
    * Any semantic tag that isn't a mathematical finite set
    * Floating point numbers
    * Undefined special value

    CBOR types are decoded to Python types as follows:

    uint -> int
    negint -> int
    bytestring -> bytes
    map -> dict
    array -> list
    True -> bool
    False -> bool
    null -> None
    indefinite length bytestring chunk -> [bytestringchunk]

    The only non-obvious mapping here is an indefinite length bytestring
    to the ``bytestringchunk`` type. This is to facilitate streaming
    indefinite length bytestrings out of the decoder and to differentiate
    a regular bytestring from an indefinite length bytestring.
    rrrrrrr	cCs$d|_|j|_g|_d|_g|_dSrE)�decodedbytecount�_STATE_NONE�_state�_collectionstack�_currentmapkey�_decodedvalues�r�rrr �__init__4s
zsansiodecoder.__init__cCs|j|jkS)z2Whether the decoder has partially decoded a value.)r�r�r�rrr �
inprogressGszsansiodecoder.inprogresscCsr|st|j�ddfS|}|t|�k�r^t||�\}}}}|dkrN|j|7_|st|dks^J�t|j�|||fS||7}|j|jk�r4|tkr�|j�|�n�|t	kr�|j
�|gd��|j|_nl|tkr�|j
�|id��|j
|_nH|tk�r|j
�|t�d��|j|_n |tk�r$|j|_ntd|���n�|j|jk�r�|tk�rx|j
d}|d�|�|dd8<�q�|t	k�r�|j
d}	g}
|	d�|
�|	dd8<|j
�||
d��n�|tk�r|j
d}	i}
|	d�|
�|	dd8<|j
�||
d��|j
|_nt|tk�rh|j
d}	t�}
|	d�|
�|	dd8<|j
�||
d��|j|_n |tk�r|td��ntd	|���nF|j|j
k�r�|tk�r�||_|j|_n:|tk�r�td
��n&|t	ttfv�r�td��ntd|���n�|j|jk�r`|tk�r>|j
d}	||	d|j<|	dd8<|j
|_�n|t	k�r�|j
d}	g}
|
|	d|j<|	dd8<|j
�||
d��|j|_n�|tk�r�|j
d}	i}
|
|	d|j<|	dd8<|j
�||
d��|j
|_nt|tk�r6|j
d}	t�}
|
|	d|j<|	dd8<|j
�||
d��|j|_n |tk�rJtd
��ntd|��d|_�nr|j|jk�r�|tk�r�|j
d}	|	d�|�|	dd8<n:|tk�r�td��n&|t	ttfv�r�td��ntd|��n�|j|jk�rX|tk�r|j�t|dd��|j|_nB|tk�rJ|j�tdddd��|j
�r@J�|j|_ntd|��nz|j|jk�r�|tk�r�|j�t|��n@|tk�r�|j�tddd��|j
�r�J�|j|_ntd|��ntd|j��|j|j|j
|jfv�r�q|j
d}	|	d�rq|j
��|j
�r@t|jt|j
t|jit|j
dd�|_n|j�|	d�|j|_�q�qt|j�||dfS)a�Attempt to decode bytes from an input buffer.

        ``b`` is a collection of bytes and ``offset`` is the byte
        offset within that buffer from which to begin reading data.

        ``b`` must support ``len()`` and accessing bytes slices via
        ``__slice__``. Typically ``bytes`` instances are used.

        Returns a tuple with the following fields:

        * Bool indicating whether values are available for retrieval.
        * Integer indicating the number of bytes that were fully consumed,
          starting from ``offset``.
        * Integer indicating the number of bytes that are desired for the
          next call in order to decode an item.
        r)�	remaining�vsunhandled special state: %drcr�r�rs9indefinite length bytestrings not allowed as array valuess5unhandled special item when expecting array value: %ds5indefinite length bytestrings not allowed as map keyss%collections not supported as map keyss1unhandled special item when expecting map key: %ds7indefinite length bytestrings not allowed as map valuess3unhandled special item when expecting map value: %dNs7indefinite length bytestrings not allowed as set valuess%collections not allowed as set valuess3unhandled special item when expecting set value: %dT)r�rH)r�r�s<unexpected special value when expecting bytestring chunk: %d)r�sunhandled decoder state: %d)�boolr�r$rkr�r�r�rf�appendrir��_STATE_WANT_ARRAY_VALUErj�_STATE_WANT_MAP_KEYrl�set�_STATE_WANT_SET_VALUErg�"_STATE_WANT_BYTESTRING_CHUNK_FIRSTr[r��_STATE_WANT_MAP_VALUE�addr��'_STATE_WANT_BYTESTRING_CHUNK_SUBSEQUENTrr�pop�list�dictr;)r�rQrsZ
initialoffsetrvrKrwrz�cZlastcZnewvaluerrr �decodeLs����
��

��


�



��


�


��

���


�����



��


��


��

���



�����

�

�
��


����


���zsansiodecoder.decodecCst|j�}g|_|S)z�Returns an iterator over fully decoded values.

        Once values are retrieved, they won't be available on the next call.
        )r�r�)r�r/rrr �getavailable�s
zsansiodecoder.getavailableN)r)r<r\r]r^r�r�r�r�r�r�r�r��propertyr�r�r�rrrr r��s 8

r�c@s(eZdZdZdd�Zdd�Zdd�ZdS)	�bufferingdecoderahA CBOR decoder that buffers undecoded input.

    This is a glorified wrapper around ``sansiodecoder`` that adds a buffering
    layer. All input that isn't consumed by ``sansiodecoder`` will be buffered
    and concatenated with any new input that arrives later.

    TODO consider adding limits as to the maximum amount of data that can
    be buffered.
    cCst�|_g|_d|_dSrE)r��_decoder�_chunks�_wantedr�rrr r��szbufferingdecoder.__init__cCs�t|t�rt|�}|jr�t|�|jkrP|j�|�|jt|�8_dd|jfSt|�}|j�|�d�|j�}g|_t|�|}nd}|j�	|�\}}}||_|t|�kr�|j�||d��||||fS)a0Attempt to decode bytes to CBOR values.

        Returns a tuple with the following fields:

        * Bool indicating whether new values are available for retrieval.
        * Integer number of bytes decoded from the new input.
        * Integer number of bytes wanted to decode the next value.
        FrrHN)
rX�	bytearrayr�r�r$r�r��joinr�r�)r�rQZnewlenZoldlenZ	availablerwryrrr r��s$
zbufferingdecoder.decodecCs
|j��Sr")r�r�r�rrr r�#szbufferingdecoder.getavailableN)r<r\r]r^r�r�r�rrrr r��s
3r�cCsH|sgSt�}|�|�\}}}|t|�kr2td��|jr@td��|��S)avDecode all CBOR items present in an iterable of bytes.

    In addition to regular decode errors, raises CBORDecodeError if the
    entirety of the passed buffer does not fully decode to complete CBOR
    values. This includes failure to decode any value, incomplete collection
    types, incomplete indefinite length items, and extra data at the end of
    the buffer.
    sinput data not fully consumedsinput data not complete)r�r�r$r[r�r�)rQ�decoderZ
havevaluesrwZ	wantbytesrrr �	decodeall's	r�)r)r)rF)QZ
__future__r�struct�sys�rr2r3r#rhr6rIr@rmrdrnrorpZSUBTYPE_HALF_FLOATZSUBTYPE_SINGLE_FLOATZSUBTYPE_DOUBLE_FLOATrqrArr(r9rM�Structrrrrrr)Z	BREAK_INTr!r'r,r0r5r8r:r=rDrLrNrRrTr��intZlongr��tupler�r�r�r;rUr7�	Exceptionr[�version_info�majorr`r|r}r~rrfrgrirjrlrrrkrer��objectr�r�r�rrrr �<module>s�
���







	
�







3pG

Youez - 2016 - github.com/yon3zu
LinuXploit