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__/util.cpython-311.pyc

�

�܋f0���ddlZddlZddlZddlZddlZddlZddlmZddlm	Z	m
Z
mZe
��Zddl
Z
	ddlmZn!#e$rddlmZmZe��Zdd�ZYnwxYwejZejZejZejjZejZejZejjZejjZej Z ejj!Z!ejj"Z"ejj#Z#ej$Z$ej%Z%ej&Z&ej'Z'd�Z(d�Z)dd	l*m+Z+m,Z,Gd
�d��Z-d�Z.dd�Z/d�Z0dd�Z1dd�Z2dd�Z3d�Z4d�Z5Gd�d��Z6Gd�d��Z7dS)�N)�BytesIO)�StaticWindowMapManager�SlidingWindowMapManager�SlidingWindowMapBuffer)�unpack_from)�unpack�calcsizec��	t|}n)#t$rt|��}|t|<YnwxYwt|||||z���S�N)�__calcsize_cache�KeyErrorr	r)�fmt�data�offset�sizes    �[/builddir/build/BUILD/cloudlinux-venv-1.0.6/venv/lib/python3.11/site-packages/gitdb/util.pyrr!sj��	)�#�C�(�D�D���	)�	)�	)��C�=�=�D�$(��S�!�!�!�	)�����c�4����
� 5�6�7�7�7s�
�#6�6c���tjdkrHtd��D]0}	||i|��cS#t$rt	jd��Y�-wxYw||i|��S||i|��S)N�win32�
g�������?)�sys�platform�range�	Exception�time�sleep)�func�args�kwargs�_s    r�_retryr Ds����|�w����r���	 �	 �A�
 ��t�T�,�V�,�,�,�,�,���
 �
 �
 ��
�3������
 �����t�T�$�V�$�$�$��t�T�$�V�$�$�$s�-�A�
Ac�6�ttjg|�Ri|��Sr)r �os�remove)rrs  rr#r#Rs"���"�)�-�d�-�-�-�f�-�-�-�)�NULL_BIN_SHA�NULL_HEX_SHAc�6�eZdZdZdZd
d�Zd�Zd�Zd�Zd�Z	d	S)�_RandomAccessBytesIOz�Wrapper to provide required functionality in case memory maps cannot or may
    not be used. This is only really required in python 2.4�_sio�c�.�t|��|_dSr)rr))�self�bufs  r�__init__z_RandomAccessBytesIO.__init__gs���C�L�L��	�	�	r$c�,�t|j|��Sr)�getattrr)�r,�attrs  r�__getattr__z _RandomAccessBytesIO.__getattr__js���t�y�$�'�'�'r$c�D�t|�����Sr)�len�getvalue�r,s r�__len__z_RandomAccessBytesIO.__len__ms���4�=�=�?�?�#�#�#r$c�6�|���|Sr�r6)r,�is  r�__getitem__z _RandomAccessBytesIO.__getitem__ps���}�}���q�!�!r$c�:�|���||�Srr:)r,�start�ends   r�__getslice__z!_RandomAccessBytesIO.__getslice__ss���}�}���u�S�y�)�)r$N)r*)
�__name__�
__module__�__qualname__�__doc__�	__slots__r.r3r8r<r@�r$rr(r(ass������?�?��I�!�!�!�!�(�(�(�$�$�$�"�"�"�*�*�*�*�*r$r(c�F�	t|��S#t$r|cYSwxYw)z�
    Return the integer representation of the byte string.  This supports Python
    3 byte arrays as well as standard strings.
    )�ord�	TypeError)�bs r�byte_ordrKws6��
��1�v�v�
�������������s�� � r$c��	tj|��S#t$rddl}|�|��}|cYSwxYw)z`A python2.4 workaround for the sha/hashlib module fiasco

    **Note** From the dulwich project rN)�hashlib�sha1�	NameError�sha)�sourcerPrNs   r�make_sharR�sS����|�F�#�#�#�������
�
�
��w�w�v�����������s��%>�>c��|dkrtd��S	tjd|��S#t$rtd|z��cYSwxYw)zB:return: a file-protocol accessible memory block of the given sizerr$����)r(�mmap�OSError)rs r�allocate_memoryrX�se���q�y�y�#�C�(�(�(�2��y��T�"�"�"���2�2�2�
$�E�D�L�1�1�1�1�1�2���s�,�A�
AFTc�|�	|rj	tj|dtj���S#t$r;tj|tj|��jtj���cYSwxYwn#t$rYnwxYwtj|tj|��j��}|rt|��S|S)a�:return: read-only contents of the file represented by the file descriptor fd

    :param fd: file descriptor opened for reading
    :param stream: if False, random access is provided, otherwise the stream interface
        is provided.
    :param allow_mmap: if True, its allowed to map the contents into memory, which
        allows large files to be handled and accessed efficiently. The file-descriptor
        will change its position if this is Falser)�access)rV�ACCESS_READrWr"�fstat�st_size�readr()�fd�stream�
allow_mmap�contentss    r�file_contents_rorc�s���

��	T�
T��y��Q�t�/?�@�@�@�@���
T�
T�
T��y��R�X�b�\�\�%9�$�BR�S�S�S�S�S�S�
T����		T���
�
�
���
����
�w�r�2�8�B�<�<�/�0�0�H�
�.�#�H�-�-�-��Os-�A/� &�AA+�(A/�*A+�+A/�/
A<�;A<c	���tj|tjttdd��z|z��}	t	|||��t|��S#t|��wxYw)a<Get the file contents at filepath as fast as possible

    :return: random access compatible memory of the given filepath
    :param stream: see ``file_contents_ro``
    :param allow_mmap: see ``file_contents_ro``
    :param flags: additional flags to pass to os.open
    :raise OSError: If the file could not be opened

    **Note** for now we don't try to use O_NOATIME directly as the right value needs to be
    shared per database in fact. It only makes a real difference for loose object
    databases anyway, and they use it with the help of the ``flags`` parameter�O_BINARYr)r"�open�O_RDONLYr0rc�close)�filepathr`ra�flagsr_s     r�file_contents_ro_filepathrk�s^��
���2�;���Z��)C�)C�C�e�K�	L�	L�B����F�J�7�7�
�b�	�	�	�	���b�	�	�	�	���s�A�A,c�T�tt�|��|���S)z�
    :return: a buffer compatible object which uses our mapped memory manager internally
        ready to read the whole given filepath)rj)r�mman�make_cursor)rirjs  r�sliding_ro_bufferro�s%��"�$�"2�"2�8�"<�"<�E�J�J�J�Jr$c�J�t|��dkr|St|��S)z!:return: hexified version  of sha�()r5�
bin_to_hex�rPs r�
to_hex_shart�s"��
�3�x�x�2�~�~��
��c�?�?�r$c�J�t|��dkr|St|��S)N�)r5�
hex_to_binrss r�
to_bin_sharx�s"��
�3�x�x�2�~�~��
��c�?�?�r$c�2�eZdZdZe��Zd�Zd�ZdS)�	LazyMixina?
    Base class providing an interface to lazily retrieve attribute values upon
    first access. If slots are used, memory will only be reserved once the attribute
    is actually accessed and retrieved the first time. All future accesses will
    return the cached value as stored in the Instance's dict or slot.
    c�b�|�|��t�||��S)z�
        Whenever an attribute is requested that we do not know, we allow it
        to be created and set. Next time the same attribute is requested, it is simply
        returned from our dict/slots. )�_set_cache_�object�__getattribute__r1s  rr3zLazyMixin.__getattr__�s.��
	
��������&�&�t�T�2�2�2r$c��dS)a�
        This method should be overridden in the derived class.
        It should check whether the attribute named by attr can be created
        and cached. Do nothing if you do not know the attribute or call your subclass

        The derived class may create as many additional attributes as it deems
        necessary in case a git command returns more information than represented
        in the single attribute.NrFr1s  rr|zLazyMixin._set_cache_s	��	
�r$N)rArBrCrD�tuplerEr3r|rFr$rrzrz�sI������������I�3�3�3�	
�	
�	
�	
�	
r$rzc�D�eZdZdZdZd�Zd�Zd�Zd
d�Zd�Z	d	�Z
dd�ZdS)�LockedFDa
    This class facilitates a safe read and write operation to a file on disk.
    If we write to 'file', we obtain a lock file at 'file.lock' and write to
    that instead. If we succeed, the lock file will be renamed to overwrite
    the original file.

    When reading, we obtain a lock file, but to prevent other writers from
    succeeding while we are reading the file.

    This type handles error correctly in that it will assure a consistent state
    on destruction.

    **note** with this setup, parallel reading is not possible��	_filepath�_fd�_writec�0�||_d|_d|_dS)z.Initialize an instance with the givne filepathNr�)r,ris  rr.zLockedFD.__init__s��!����������r$c�@�|j�|���dSdSr)r��rollbackr7s r�__del__zLockedFD.__del__$s#���8���M�M�O�O�O�O�O� �r$c��d|jzS)Nz%s.lock)r�r7s r�
_lockfilepathzLockedFD._lockfilepath)s���4�>�)�)r$Fc���|j�td|jz���||_ttdd��}tjtjztjz|z}	t	j|���|tdd����}|st	j
|��n||_n7#t$r*}td|���z��|�d}~wwxYw|j�U	t	j|j
tj|z��|_n'#t|������xYw|rddlm}||j��S|jS)	a�
        Open the file descriptor for reading or writing, both in binary mode.

        :param write: if True, the file descriptor will be opened for writing. Other
            wise it will be opened read-only.
        :param stream: if True, the file descriptor will be wrapped into a simple stream
            object which supports only reading or writing
        :return: fd to read from or write to. It is still maintained by this instance
            and must not be closed directly
        :raise IOError: if the lock could not be retrieved
        :raise OSError: If the actual file could not be opened for reading

        **note** must only be called onceNzCalled %s multiple timesrer�600�z Lock at %r could not be obtained)�FDStream)r��AssertionErrorrfr0r"�O_WRONLY�O_CREAT�O_EXCLr��intrhr�rWr�rgr#�gitdb.streamr�)r,�writer`�binary�lockmoder_�er�s        rrfz
LockedFD.open,sp���;�"� �!;�d�i�!G�H�H�H������Z��+�+���;���+�b�i�7�&�@��	\����+�+�-�-�x��U�A���G�G�B��
��������������	\�	\�	\��<�t�?Q�?Q�?S�?S�S�T�T�Z[�[�����	\����
�8��
��7�4�>�2�;��3G�H�H�����
��t�)�)�+�+�,�,�,������	�-�-�-�-�-�-��8�D�H�%�%�%��8�Os%�&AB;�;
C/�%C*�*C/�:,D'�'$Ec�2�|�d���dS)z�When done writing, call this function to commit your changes into the
        actual file.
        The file descriptor will be closed, and the lockfile handled.

        **Note** can be called multiple timesT��
successfulN��_end_writingr7s r�commitzLockedFD.commitas!��	
���T��*�*�*�*�*r$c�2�|�d���dS)z�Abort your operation without any changes. The file descriptor will be
        closed, and the lock released.

        **Note** can be called multiple timesFr�Nr�r7s rr�zLockedFD.rollbackis!��
	
���U��+�+�+�+�+r$Tc���|j�td���|j�dStj|j��d|_|���}|jry|rwtjdkr(t|j	��rt|j	��tj||j	��t|j	tdd����dSt|��dS)z,Handle the lock according to the write mode Nz-Cannot end operation if it wasn't started yetr�644r�)r�r�r�r"rhr�rr�isfiler�r#�rename�chmodr�)r,r��lockfiles   rr�zLockedFD._end_writingps����;�� �!P�Q�Q�Q��8���F�
�����������%�%�'�'���;�	�:�	��|�w�&�&��$�.�)�)�+��4�>�*�*�*�
�I�h���/�/�/�

�$�.�#�e�Q�-�-�0�0�0�0�0�
�8�����r$N)FF)T)rArBrCrDrEr.r�r�rfr�r�r�rFr$rr�r�
s�������B�B�/�I�������
*�*�*�2�2�2�2�j+�+�+�,�,�,������r$r�)r)r$)FT)FTr)8�binasciir"rVrr�errno�ior�smmaprrrrmrM�structr�ImportErrorrr	�dictr�a2b_hexrw�b2a_hexrr�ENOENT�path�exists�mkdirr��isdirr�r��dirname�basename�joinr^r�rh�fsyncr r#�gitdb.constr%r&r(rKrRrXrcrkrortrxrzr�rFr$r�<module>r�s���
����	�	�	�	�����
�
�
�
��������������������������� � ������
8�"�"�"�"�"�"�"���8�8�8�'�'�'�'�'�'�'�'��t�v�v��8�8�8�8�8�8�	8����"�
�
�
�
�
�
���
����
���
���
��
��	����	���
�'�/��
�7���	�w�|��	�w��
���
���
���%�%�%�.�.�.�
��������*�*�*�*�*�*�*�*�,���	�	�	�	�
2�
2�
2�"����:����(K�K�K�K�������
�
�
�
�
�
�
�
�@~�~�~�~�~�~�~�~�~�~s�?�A�A

Zerion Mini Shell 1.0