ok

Mini Shell

Direktori : /opt/cloudlinux/venv/lib64/python3.11/site-packages/gitdb/__pycache__/
Upload File :
Current File : //opt/cloudlinux/venv/lib64/python3.11/site-packages/gitdb/__pycache__/stream.cpython-311.pyc

�

�܋fxk���ddlmZddlZddlZddlZddlZddlmZmZm	Z	m
Z
mZddlm
Z
mZmZmZmZddlmZmZddlmZdZ	ddlmZd	Zn#e$rYnwxYwd
ZGd�de��ZGd
�de��ZGd�d��ZGd�de��Z Gd�de��Z!Gd�de��Z"Gd�d��Z#Gd�d��Z$dS)�)�BytesION)�msb_size�stream_copy�apply_delta_data�connect_deltas�delta_types)�allocate_memory�	LazyMixin�make_sha�write�close)�	NULL_BYTE�
BYTE_SPACE)�force_bytesF)�apply_deltaT)	�DecompressMemMapReader�FDCompressedSha1Writer�DeltaApplyReader�
Sha1Writer�FlexibleSha1Writer�ZippedStoreShaWriterr�FDStream�
NullStreamc��eZdZdZdZdZdd�Zd�Zd�Zd�Z	e
dd
���Zd�Zd�Z
d
�Zeedd��fd�Zdd�ZdS)ra�Reads data in chunks from a memory map and decompresses it. The client sees
    only the uncompressed data, respective file-like read calls are handling on-demand
    buffered decompression accordingly

    A constraint on the total size of bytes is activated, simulating
    a logical file within a possibly larger physical memory area

    To read efficiently, you clearly don't want to read individual bytes, instead,
    read a few kilobytes at least.

    **Note:** The chunk-size should be carefully selected as it will involve quite a bit
        of string copying due to the way the zlib is implemented. Its very wasteful,
        hence we try to find a good tradeoff between allocation time and number of
        times we actually allocate. An own zlib implementation would be good here
        to better support streamed reading - it would only need to keep the mmap
        and decompress it into chunks, that's all ... )�_m�_zip�_buf�_buflen�_br�_cws�_cwe�_s�_close�_cbr�_phiiNc���||_tj��|_d|_d|_|�||_d|_d|_d|_	d|_
d|_||_dS)z|Initialize with mmap for stream reading
        :param m: must be content data - use new if you have object data and no sizeNrF)
r�zlib�
decompressobjrrrr"rr r!r$r%r#)�self�m�close_on_deletion�sizes    �]/builddir/build/BUILD/cloudlinux-venv-1.0.6/venv/lib/python3.11/site-packages/gitdb/stream.py�__init__zDecompressMemMapReader.__init__Esd������&�(�(��	���	�������D�G������	���	���	���	�'�����c�>�|dksJ�|���dS)Nr")�_parse_header_info�r)�attrs  r-�_set_cache_z"DecompressMemMapReader._set_cache_Us)���t�|�|�|�|�	
���!�!�!�!�!r/c�.�|���dS�N)r
�r)s r-�__del__zDecompressMemMapReader.__del__[s���
�
�����r/c�|�d}||_|�|��}|�t��}|d|��t
��\}}t
|��}||_d|_|dz
}t||d���|_	t|��|z
|_d|_||fS)z�If this stream contains object data, parse the header info and skip the
        stream to a point where each read will yield object content

        :return: parsed type_string, sizei Nr�T)
r"�read�findr�splitr�intrrr�lenrr%)r)�maxb�hdr�hdrend�typr,s      r-r1z)DecompressMemMapReader._parse_header_info^s���������i�i��o�o�����)�$�$������L�&�&�z�2�2�	��T��4�y�y���������!����C����L�)�)��	��3�x�x�&�(�����	��D�y�r/Fc�\�t||d��}|���\}}|||fS)a�Create a new DecompressMemMapReader instance for acting as a read-only stream
        This method parses the object header from m and returns the parsed
        type and size, as well as the created stream instance.

        :param m: memory map on which to operate. It must be object data ( header + contents )
        :param close_on_deletion: if True, the memory map will be closed once we are
            being deletedr)rr1)r)r*r+�instrCr,s      r-�newzDecompressMemMapReader.new{s7��&�a�):�A�>�>���+�+�-�-�	��T��D�$��r/c��|jS)z8:return: random access compatible data we are working on)rr7s r-�datazDecompressMemMapReader.data�s	���w�r/c��|jr7t|jd��r|j���d|_dSdS)z�Close our underlying stream of compressed bytes if this was allowed during initialization
        :return: True if we closed the underlying stream
        :note: can be called safely 
        r
FN)r#�hasattrrr
r7s r-r
zDecompressMemMapReader.close�sF��
�;�	 ��t�w��(�(�
 ���
�
�����D�K�K�K�	 �	 r/c�"�|j|jkr�|jjs�d|_t	|jd��rT|jjtjkr9|�tj
��|jjtjk�9nq|jjse|jt|j
��krH|�tj
��|jjs|jt|j
��k�H|j|_|jS)z�
        :return: number of compressed bytes read. This includes the bytes it
            took to decompress the header ( if there was one )r�status)rr"r�unused_datarJrLr'�Z_OKr;�mmap�PAGESIZEr$r?rr7s r-�compressed_bytes_readz,DecompressMemMapReader.compressed_bytes_read�s���0�8�t�w���t�y�'<���D�H��t�y�(�+�+�
-��i�&�$�)�3�3��I�I�d�m�,�,�,��i�&�$�)�3�3��
�)�/�-�D�I��T�W���4M�4M��I�I�d�m�,�,�,��)�/�-�D�I��T�W���4M�4M��w�D�H�
�y�r/�SEEK_SETrc���|dks|ttdd��krtd���tj��|_dx|_x|_x|_|_	|j
rd|_
|`dSdS)zgAllows to reset the stream to restart reading
        :raise ValueError: If offset and whence are not 0rrR�Can only seek to position 0FN)�getattr�os�
ValueErrorr'r(rrr r!r$r%r"�r)�offset�whences   r-�seekzDecompressMemMapReader.seek�s����Q�;�;�&�G�B�
�A�$>�$>�>�>��:�;�;�;��&�(�(��	�78�8���8�4�9�8�t�y�4�9��9�	��D�I�����	�	r/���c�R�|dkr|j|jz
}nt||j|jz
��}|dkrdSd}|jr�|j|kr<|j�|��}|xj|zc_|xj|z
c_|S|j���}||jz}|xj|jz
c_d|_d|_|jj}|r,|jt|��z
|_
|j
|z|_n|j
}|j|_
||z|_|j|j
z
dkr|j
dz|_|j|j
|j�}|j
t|��z|_|j�||��}tjdvr*tjdkst|jj��}n3t|jj��t|jj��z}|xjt|��|z
z
c_|xjt|��z
c_|r||z}|r[t|��t|��z
|kr8|j|jkr(||�|t|��z
��z
}|S)Nr:rr/�)z1.2.7z1.2.5�darwin)r"r�minrrr;r�unconsumed_tailr!r?r r�
decompressr'�ZLIB_VERSION�sys�platformrMr$)r)r,�dat�tail�cws�indata�dcompdat�unused_datalens        r-r;zDecompressMemMapReader.read�s����!�8�8��7�T�X�%�D�D��t�T�W�t�x�/�0�0�D��1�9�9��3����9�
	!��|�t�#�#��i�n�n�T�*�*������$������D� ����
��i�n�n�&�&�����$�����D�L�(��� ��� ��	��y�(���	#��	�C��I�I�-�D�I��	�D�(�D�I�I��)�C��	�D�I��d�
�D�I��9�t�y� �1�$�$��	�A�
�D�I�����4�9�,�-���I��F���+��	��9�'�'���5�5���� 2�2�2�3�<�8�;S�;S� ���!:�;�;�N�N� ���!:�;�;�c�$�)�BW�>X�>X�X�N�	
�	�	�S��[�[�>�1�1�	�	����C��M�M�!����	&��X�~�H��	8��X����S���1�T�9�9�d�h���>P�>P���	�	�$��X���"6�7�7�7�H��r/r6�F)r\)�__name__�
__module__�__qualname__�__doc__�	__slots__�
max_read_sizer.r4r8r1�classmethodrFrHr
rQrUrVr[r;�r/r-rr.s�������:�:� !�I��M�(�(�(�(� "�"�"�������:�
�
�
��[�
���� � � �-�-�-�b#*�'�"�j�!�"<�"<�����i�i�i�i�i�ir/rc��eZdZdZdZdZd�Zd�Zd�Ze	seZ
neZ
dd�Zee
d	d��fd
�Zed���Zed���Zed
���Zed���ZdS)ra�A reader which dynamically applies pack deltas to a base object, keeping the
    memory demands to a minimum.

    The size of the final object is only obtainable once all deltas have been
    applied, unless it is retrieved from a pack index.

    The uncompressed Delta has the following layout (MSB being a most significant
    bit encoded dynamic size):

    * MSB Source Size - the size of the base against which the delta was created
    * MSB Target Size - the size of the resulting data after the delta was applied
    * A list of one byte commands (cmd) which are followed by a specific protocol:

     * cmd & 0x80 - copy delta_data[offset:offset+size]

      * Followed by an encoded offset into the delta data
      * Followed by an encoded size of the chunk to copy

     *  cmd & 0x7f - insert

      * insert cmd bytes from the delta buffer into the output stream

     * cmd == 0 - invalid operation ( or error in delta stream )
    )�_bstream�	_dstreams�
_mm_target�_sizeri���c��t|��dks
Jd���|d|_t|dd���|_d|_dS)z�Initialize this instance with a list of streams, the first stream being
        the delta to apply on top of all following deltas, the last stream being the
        base object onto which to apply the deltasr:z+Need at least one delta and one base streamr\Nr)r?rv�tuplerwr)r)�stream_lists  r-r.zDeltaApplyReader.__init__hsT���;���!�#�#�#�%R�#�#�#�#�B���
��{�3�B�3�/�0�0�������r/c�p�t|j��dkr|�|��St|j��}|���dkrd|_t
d��|_dS|���|_t
|j��|_t
|jj	��}t|jj|j|jj	dtjz��|jj}|�||��|j�d��dS)Nr:r�)r?rw�_set_cache_brute_r�rboundryr	rxrvr,rr;rrOrP�applyr[)r)r3�dcl�bbufrs     r-�_set_cache_too_slow_without_cz.DeltaApplyReader._set_cache_too_slow_without_crs���t�~���!�#�#��)�)�$�/�/�/�
�T�^�,�,���:�:�<�<�1����D�J�-�a�0�0�D�O��F��Z�Z�\�\��
�)�$�*�5�5����t�}�1�2�2���D�M�&��
�D�M�4F��d�m�H[�\�\�\���%���	�	�$���������Q�����r/c	�N�t��}d}|jD]m}|�d��}t|��\}}t||��\}}|�||d�|||f��t||��}�n|jj}	|}t|j��dkrt|	|��x}	}t|	��}
t|jj|
j|	dtj
z��t|��}d}tt|��t|j����D]�\\}
}}}}t|j|z
��}|�|
��t|j|j|jdtj
z��dt!��vrt#|
||��n%t%|
||t|��|j��||
}}
|
�d��|�d��|}��|
|_||_dS)z*If we are here, we apply the actual deltasriNr:r~�
c_apply_delta)�listrwr;r�append�maxrvr,r?r	rrrOrP�zip�reversed�globalsr�rr[rxry)r)r3�buffer_info_list�max_target_size�dstream�bufrY�src_size�target_size�	base_sizer��tbuf�final_target_size�dbuf�ddatas               r-rz"DeltaApplyReader._set_cache_brute_�s%��
 �6�6�����~�	@�	@�G��,�,�s�#�#�C�'��}�}��F�H�"*�3��"7�"7��F�K��#�#�S����\�6�8�[�$Q�R�R�R�!�/�;�?�?�O�O�
�M�&�	�%���t�~����"�"�&)�)�_�&E�&E�E�I��
�y�)�)���D�M�&��
�I�s�T�]�?R�S�S�S��{�+�+��!��>A�(�K[�B\�B\�^f�gk�gu�^v�^v�>w�>w�	,�	,�:�1�T�6�8�[�7�$�G�L�6�$9�:�:�E��K�K��������e�k�7�<��t�}�AT�U�U�U��'�)�)�+�+��d�E�4�0�0�0�0� ��x���E�
�
�D�J�O�O�O�
�t�$�D��I�I�a�L�L�L��I�I�a�L�L�L� +������&��
�
�
r/rc��|j|jz
}|dks||kr|}|j�|��}|xjt	|��z
c_|S)Nr:)ryrrxr;r?)r)�count�blrHs    r-r;zDeltaApplyReader.read�sX��
�Z�$�(�
"���1�9�9���
�
��E���#�#�E�*�*�����C��I�I�����r/rRc��|dks|ttdd��krtd���d|_|j�d��dS)zhAllows to reset the stream to restart reading

        :raise ValueError: If offset and whence are not 0rrRrTN)rUrVrWrrxr[rXs   r-r[zDeltaApplyReader.seek�sU���Q�;�;�&�G�B�
�A�$>�$>�>�>��:�;�;�;��������Q�����r/c��t|��dkrtd���|djtvrtd|djz���||��S)a
        Convert the given list of streams into a stream which resolves deltas
        when reading from it.

        :param stream_list: two or more stream objects, first stream is a Delta
            to the object that you want to resolve, followed by N additional delta
            streams. The list's last stream must be a non-delta stream.

        :return: Non-Delta OPackStream object whose stream can be used to obtain
            the decompressed resolved data
        :raise ValueError: if the stream list cannot be handled�zNeed at least two streamsr\zNCannot resolve deltas if there is no base object stream, last one was type: %s)r?rW�type_idr�type)�clsr|s  r-rFzDeltaApplyReader.new�ss���{���a����8�9�9�9��r�?�"�k�1�1��`�cn�oq�cr�cw�w�y�y�
y��s�;���r/c��|jjSr6)rvr�r7s r-r�zDeltaApplyReader.types
���}�!�!r/c��|jjSr6)rvr�r7s r-r�zDeltaApplyReader.type_ids
���}�$�$r/c��|jS)z3:return: number of uncompressed bytes in the stream)ryr7s r-r,zDeltaApplyReader.sizes���z�r/N�r)rmrnrorprq�k_max_memory_mover.r�r�has_perf_modr4r;rUrVr[rsrF�propertyr�r�r,rtr/r-rrBs��������0�I�*�����  �  �  �DH'�H'�H'�V�4�'���3������#*�'�"�j�!�"<�"<� � � � �� � ��[� �4�"�"��X�"��%�%��X�%�����X���r/rc�*�eZdZdZdZd�Zd�Zdd�ZdS)	rzpSimple stream writer which produces a sha whenever you like as it degests
    everything it is supposed to write�sha1c�,�t��|_dSr6)rr�r7s r-r.zSha1Writer.__init__2s���J�J��	�	�	r/c�T�|j�|��t|��S)z{:raise IOError: If not all bytes could be written
        :param data: byte object
        :return: length of incoming data)r��updater?�r)rHs  r-rzSha1Writer.write7s&��
	
�	��������4�y�y�r/Fc�j�|r|j���S|j���S)z]:return: sha so far
        :param as_hex: if True, sha will be hex-encoded, binary otherwise)r��	hexdigest�digest)r)�as_hexs  r-�shazSha1Writer.shaDs4���	)��9�&�&�(�(�(��y���!�!�!r/Nrl)rmrnrorprqr.rr�rtr/r-rr,sU������*�*��I����
���"�"�"�"�"�"r/rc�"�eZdZdZdZd�Zd�ZdS)rzZWriter producing a sha1 while passing on the written bytes to the given
    write function�writerc�H�t�|��||_dSr6)rr.r�)r)r�s  r-r.zFlexibleSha1Writer.__init__Ts!�����D�!�!�!�����r/c�f�t�||��|�|��dSr6)rrr�r�s  r-rzFlexibleSha1Writer.writeXs0������t�$�$�$����D�����r/N)rmrnrorprqr.rrtr/r-rrNsA���������I��������r/rc�T�eZdZdZdZd�Zd�Zd�Zd�Ze	e
dd��fd	�Zd
�ZdS)rz=Remembers everything someone writes to it and generates a sha)r�r�c��t�|��t��|_t	jtj��|_dSr6)rr.rr�r'�compressobj�Z_BEST_SPEEDr�r7s r-r.zZippedStoreShaWriter.__init__bs:�����D�!�!�!��9�9����#�D�$5�6�6����r/c�,�t|j|��Sr6)rUr�r2s  r-�__getattr__z ZippedStoreShaWriter.__getattr__gs���t�x��&�&�&r/c��t�||��}|j�|j�|����|Sr6)rrr�r��compress)r)rH�alens   r-rzZippedStoreShaWriter.writejs@������d�+�+������t�x�(�(��.�.�/�/�/��r/c�h�|j�|j�����dSr6)r�rr��flushr7s r-r
zZippedStoreShaWriter.closeps(������t�x�~�~�'�'�(�(�(�(�(r/rRrc��|dks|ttdd��krtd���|j�d��dS)z`Seeking currently only supports to rewind written data
        Multiple writes are not supportedrrRrTN)rUrVrWr�r[rXs   r-r[zZippedStoreShaWriter.seekssL���Q�;�;�&�G�B�
�A�$>�$>�>�>��:�;�;�;���
�
�a�����r/c�4�|j���S)zA:return: string value from the current stream position to the end)r��getvaluer7s r-r�zZippedStoreShaWriter.getvalue{s���x� � �"�"�"r/N)
rmrnrorprqr.r�rr
rUrVr[r�rtr/r-rr]s�������G�G��I�7�7�7�
'�'�'����)�)�)�#*�'�"�j�!�"<�"<�����#�#�#�#�#r/rc�H��eZdZdZdZed��Z�fd�Zd�Zd�Z	�xZ
S)rz�Digests data written to it, making the sha available, then compress the
    data and write it to the file descriptor

    **Note:** operates on raw file descriptors
    **Note:** for this to work, you have to use the close-method of this instance)�fdr�r�z+Failed to write all bytes to filedescriptorc���t�����||_tjtj��|_dSr6)�superr.r�r'r�r�r�)r)r��	__class__s  �r-r.zFDCompressedSha1Writer.__init__�s9���
������������#�D�$5�6�6����r/c���|j�|��|j�|��}t	|j|��}|t
|��kr|j�t
|��S)zZ:raise IOError: If not all bytes could be written
        :return: length of incoming data)r�r�r�r�rr�r?�exc)r)rH�cdata�
bytes_writtens    r-rzFDCompressedSha1Writer.write�sd��	
�	���������!�!�$�'�'���d�g�u�-�-�
��C��J�J�&�&��(�N��4�y�y�r/c��|j���}t|j|��t	|��kr|j�t
|j��Sr6)r�r�rr�r?r�r
)r)�	remainders  r-r
zFDCompressedSha1Writer.close�sE���H�N�N�$�$�	����)�$�$��I���6�6��(�N��T�W�~�~�r/)rmrnrorprq�IOErrorr�r.rr
�
__classcell__)r�s@r-rr�s{�������U�U�
&�I��'�?�
@�
@�C�7�7�7�7�7�
�
�
�������r/rc�<�eZdZdZdZd�Zd�Zdd�Zd�Zd�Z	d	�Z
d
S)rz�A simple wrapper providing the most basic functions on a file descriptor
    with the fileobject interface. Cannot use os.fdopen as the resulting stream
    takes ownership��_fd�_posc�"�||_d|_dS�Nrr�)r)r�s  r-r.zFDStream.__init__�s�������	�	�	r/c�t�|xjt|��z
c_tj|j|��dSr6)r�r?rVrr�r�s  r-rzFDStream.write�s2���	�	�S��Y�Y��	�	�
����4� � � � � r/rc���|dkr$tj�|j��}tj|j|��}|xjt|��z
c_|Sr�)rV�path�getsize�	_filepathr;r�r�r?)r)r��bytess   r-r;z
FDStream.read�sP���A�:�:��G�O�O�D�N�3�3�E�����%�(�(���	�	�S��Z�Z��	�	��r/c��|jSr6)r�r7s r-�filenozFDStream.fileno�s	���x�r/c��|jSr6)r�r7s r-�tellz
FDStream.tell�s
���y�r/c�.�t|j��dSr6)r
r�r7s r-r
zFDStream.close�s��
�d�h�����r/Nr�)rmrnrorprqr.rr;r�r�r
rtr/r-rr�s��������� �I����!�!�!���������������r/rc�:�eZdZdZe��Zdd�Zd�Zd�ZdS)rzVA stream that does nothing but providing a stream interface.
    Use it like /dev/nullrc��dS)N�rt)r)r,s  r-r;zNullStream.read�s���rr/c��dSr6rtr7s r-r
zNullStream.close�s���r/c� �t|��Sr6)r?r�s  r-rzNullStream.write�s���4�y�y�r/Nr�)	rmrnrorpr{rqr;r
rrtr/r-rr�s[������������I�����
�
�
�����r/r)%�iorrOrVrdr'�	gitdb.funrrrrr�
gitdb.utilr	r
rrr
�gitdb.constrr�gitdb.utils.encodingrr��gitdb_speedups._perfrr��ImportError�__all__rrrrrrrrrtr/r-�<module>r�s�������������	�	�	�	�
�
�
�
���������������������������������.�-�-�-�-�-�-�-�,�,�,�,�,�,���	�A�A�A�A�A�A��L�L���	�	�	��D�	����%��Q�Q�Q�Q�Q�Y�Q�Q�Q�h`�`�`�`�`�y�`�`�`�T"�"�"�"�"�"�"�"�D��������� #� #� #� #� #�:� #� #� #�F#�#�#�#�#�Z�#�#�#�P��������D
�
�
�
�
�
�
�
�
�
s�A
�
A�A

Zerion Mini Shell 1.0